+1 vote

Hi there,
is it possible to get the embedded images as inline base64 encoded image data on GetMessageByUID()?
like: <img src="data:image/jpeg;base64,/9j/4gIc.........">
How can this be manually be done. Maybe using VisualReplace?

Another alternative would be to download the images onthefly via a small aspx form, which responds (via header) only the attachment (bytes) of the posted id.

My preferred solution would be the inline base64-data, so it would be nice to have a built-in implementation for streaming the cid: data inline.
:)

Best regards and thanks for this sweet lib!
Frank

PS: Will be purchased soon. ;)

by (1.8k points)

1 Answer

+1 vote
 
Best answer

Take a look at IMail.GetBodyAsHtml method. If you specify inlineVisuals = true, all visuals are inlined using 'data:' URI scheme.

MailBuilder builder = new MailBuilder();
builder.Html = @"<html><body><img src=""cid:lena@mail.dll""></body></html>";
MimeData visual = builder.AddVisual("c:\\lena.jpg");
visual.ContentId = "lena@mail.dll";
IMail mail = builder.Create();

string html = mail.GetBodyAsHtml(true)

StringAssert.Contains(
    @"<img src=""data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD", 
    html);
by (301k points)
selected by
working perfektly! thx for this stunning quick reply.
Prevent inline (embedded) images from being added as attachments
...