+1 vote

Hello,

After retrieving the email from my server I noticed that the images in my email are broken. Is there a property that I need to set in order to support this?

Please advise. Thank you!

by (600 points)

1 Answer

0 votes

I assume you are talking about images embedded in the html part of the email message.

In most cases HTML body of the email references such images using special "cid:" protocol

<p>This is an image <img src="cid:logo@example.com" /></p>

CID: specifies Content-ID of the image that should be used.

This image is embedded inside an email as a visual attachment - IMail.Visuals or IMail.Attachments (as some emails might be incorrectly created by the sender).

You can use an indexer to find it:

IMail email = ...
MimeData v = email.Attachments["logo@example.com"];

Alternatively you can use IMail.GetBodyAsHtml to retrieve HTML body of the email with all visual elements inlined using 'data:' URI scheme:

IMail email = ...
string html = email.GetBodyAsHtml(true);

Which would result in the entire image encoded inside the html:

<p>This is an image <img src="data:image/png;base64,iB...AK==" /></p>
by (301k points)
Thank you for your swift response. I will try your recommendations.
...