Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add CC to SendGrid mail using C#

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);

like image 665
Tejas Avatar asked Jul 17 '20 08:07

Tejas


1 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);
like image 196
Tejas Avatar answered Oct 23 '22 05:10

Tejas