10

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

shuberman
  • 1,416
  • 6
  • 21
  • 38
Tejas
  • 296
  • 3
  • 12

1 Answers1

18

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);
Grandevox
  • 92
  • 2
  • 8
Tejas
  • 296
  • 3
  • 12
  • 3
    One thing of note here, you cannot have the same email address in a CC or BCC list as you do in the TO list or it will throw an error (which can be difficult to identify). Worth checking if you're having issues getting this to work. – big_water Sep 03 '21 at 13:28