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("receiver@gmail.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);
Console.WriteLine(response.StatusCode.ToString());
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 .
Best Regards,
Nan Yu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
33 Points
83 Posts
Email- Images
Jun 10, 2018 06:57 PM|nambir|LINK
Hi Team,
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.
https://ibb.co/jwxMco
https://ibb.co/cqe6A8
https://files.fm/u/m6xsq9ez
All-Star
18785 Points
3830 Posts
Microsoft
Re: Email- Images
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 .
Best Regards,
Nan Yu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.