How to add CC to SendGrid mail using C#

Viewed 3829

This is my code..

var client = new SendGridClient(SendGridEmailEntity.Key);

var from = new EmailAddress(SendGridEmailEntity.Mail, SendGridEmailEntity.DisplayName);

var subject = templateRecord.EmailFrm.SubjectName;

var to = new EmailAddress(activeQueueEntities[i].EmailId, activeQueueEntities[i].Name);

var plainTextContent = "";

var htmlContent = templateRecord.TemplateContent;

var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);

2 Answers

Solved using Below Code...

var client = new SendGridClient(SendGridEmailEntity.Key);
var from = new EmailAddress(SendGridEmailEntity.Mail, SendGridEmailEntity.DisplayName);
var subject = templateRecord.EmailFrm.SubjectName;
var to = new EmailAddress(activeQueueEntities[i].EmailId, activeQueueEntities[i].Name);
var htmlContent = templateRecord.TemplateContent;

var msg = new SendGridMessage()
    {
        From = from,
        Subject = subject,
        HtmlContent = htmlContent,
    };

msg.AddTo(to);
msg.AddCcs(CCs);

Sendgrid does not support CC parameter in their web api. You can use the SMTP api though. If BCC helps you can use sendGridMessage.SetBccSetting.

Related