Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

New Post: Keep inline attachment image links in HTML Mail's

$
0
0
I grepped around in the ImapX source code and cannot find any code that replaces img tags with a string like what you provided.

I suspect that what is happening is that you are grabbing the text/plain message body instead of the text/html message body.

That said, a browser control will not render img tags with a cid: source URL. In order to get those img tags to render properly, you'll need to use something like the HtmlPreviewVisitor mentioned at https://github.com/jstedfast/MailKit/blob/master/FAQ.md#HasAttachments (scroll down a few paragraphs).

That example saves the referenced images off to a temp directory and references them using a file:// URL, but the other option is to embed the image data in the HTML like this:
string GetDataImageSrc (MimePart image)
{
    using (var output = new MemoryStream ()) {
        image.ContentObject.DecodeTo (output);
        return string.Format ("data:{0};base64,{1}", image.ContentType.MimeType, Convert.ToBase64String (output.GetBuffer (), 0, (int) output.Length));
    }
}

Viewing all articles
Browse latest Browse all 1952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>