MailMessageGetHtmlWithBase64EncodedRelatedFiles Method
Gets the HTML body with all related files being embedded directly in the HTML body as base64 chunks.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public string GetHtmlWithBase64EncodedRelatedFiles()

Return Value

Type: String
A string containing the HTML body which is altered in such a way so that all Content-ID references (cid:) are replaced with base64 chunks with the contents of the related files.

This method does not save anything to disk and no I/O activity of any kind occurs (hence no async version). It's easier to use it than methods which save related file to disk. The drawback is when the message has very large images (the resulting HTML string can grow large as well). In practice, this is usually not a concern so using this method is recommended whenever possible.

// To use the code below, import MailBee namespaces at the top of your code.
using System;
using MailBee;
using MailBee.Mime;
using MailBee.ImapMail;

// The actual code (put it into a method of your class).
Imap imp = new Imap();

// Log if useful for debugging.
imp.Log.Enabled = true;
imp.Log.Filename = @"C:\Temp\log.txt";

imp.Login("", "secret");

// Download the last e-mail in Inbox.
MailMessage msg = imp.DownloadEntireMessage(imp.MessageCount, false);
string html = msg.GetHtmlWithBase64EncodedRelatedFiles();
// You can now load 'html' in WebBrowser control, etc.
See Also