MailMessageGetHtmlWithBase64EncodedRelatedFiles Method |
Namespace: MailBee.Mime
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.Log.Clear(); imp.Connect("mail.domain.com"); imp.Login("test@domain.com", "secret"); imp.SelectFolder("Inbox"); // Download the last e-mail in Inbox. MailMessage msg = imp.DownloadEntireMessage(imp.MessageCount, false); string html = msg.GetHtmlWithBase64EncodedRelatedFiles(); imp.Disconnect(); // You can now load 'html' in WebBrowser control, etc.