+1 vote

I have successfully stored the visuals of my email alongside the content-id of those visuals in my database.

Now I am trying to render the email in my email client. Html is rendered perfectly, but I am having problem embedding the visuals in the exact spots in the html where they belong. I know there is an <img> tag with src attribute that contains content-id. That is where my image should be rendered. But where in html document do i put my visual file show that img tag can find the image and render just by using that original content-id.


by (1.2k points)

1 Answer

+1 vote

This depends on your rendering engine. For example in desktop apps using IE as rendering engine it is possible to inject your own protocol handler that would react to cid: protocol and provide image data directly to the browser.

If you are in web environment, you probably need to modify the html to reference images on your web server or inline images directly using base64.

There are 2 helper methods you can use IMail.SaveHtmlAs(string fileName, bool inlineVisuals) and IMail.GetBodyAsHtml(bool inlineVisuals)

They save (along with all visuals) or return body in HTML format. When inlineVisuals parameter is set to true, all visual elements are inlined using 'data:' URI scheme.

by (298k points)