Last post Jun 11, 2018 09:09 AM by Nan Yu
Jun 10, 2018 06:57 PM|nambir|LINK
I am trying to add an image to the email template. I used send grid to send email.
I added base64 to embed image but image is displayed as numbers.
var apiKey = "key";
var client = new SendGridClient(apiKey);
var from = new EmailAddress("admin@Sender.com", "Educator");
var subject = "Sending with SendGrid is Fun"+DateTime.Now;
var to = new EmailAddress("email@example.com", "Portal");
var plainTextContent = "NOTHING";
string MailText = GetTemplate();
MailText = MailText.Replace("../Images/Image1.jpg", "data:image;base64," + GetBase64ForImage("Image1.jpg"));
//<img alt="My Image" src="data:image/jpeg;base64,/9j/4S/+RXhpZgAATU0AKgAAAAgACAESAAMAENkDZ5u8/61a+X...more encoding" />
var htmlContent = MailText;
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
Jun 11, 2018 09:09 AM|Nan Yu|LINK
Hi nambir ,
You can click
here for how to Embed Images in Your Emails using SendGrid . And according to
this thread , try to remove metadata from the base 64 encoding to check whether it helps .
Since SendGrid is a third-party plugin , i would suggest you could post your question to SendGrid Support Forum for further support .