Skip to content Skip to sidebar Skip to footer

Save Image On My Computer As HTML To Embed In Email?

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', ChartImageFor

Solution 1:

Building Proper HTML

Since you appear to be sending the body as HTML, try building an <img> tag and setting the src of it to your Base 64 encoded image data :

// Set the body of your email to an image that contains your Base64-encoded image
mailItem.HTMLBody = String.Format("<img src='{0}' />",dataUrl);

This should build your <img> tag as expected, however if will appear or not will be a matter of support.

Checking Browser and Client Support

It's worth noting that while most major browsers will support Base64 URLs, many have issues and limitations. Additionally, some e-mail clients may not support them either as seen below :

enter image description here


Post a Comment for "Save Image On My Computer As HTML To Embed In Email?"