I'm trying to convert an image I have on my computer to HTML and embed it into an email:
This is what I've tried so far:
chart1.SaveImage("C:\\My Chart\\mychart.png", ChartImageFormat.Png);
OutlookApp outlookApp = new OutlookApp();
MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
var bytes = File.ReadAllBytes("C:\\My Chart\\mychart.png");
var b64String = Convert.ToBase64String(bytes);
var dataUrl = "data:image/png;base64," + b64String;
mailItem.HTMLBody = dataUrl ;
//Set a high priority to the message
mailItem.Importance = OlImportance.olImportanceHigh;
mailItem.To = "email@email.com";
mailItem.Display(false);
This doesn't work, it shows up as a bunch of code in the actual email