MailMessageSaveHtmlAndRelatedFiles Method |
Namespace: MailBee.Mime
Exception | Condition |
---|---|
MailBeeInvalidArgumentException | filename is a null reference (Nothing in Visual Basic) or an empty string. |
MailBeeIOException | An I/O error occurred and ThrowExceptions is true. |
All links to the embedded objects (pictures, CSS tables, etc) contained in the generated HTML file are automatically corrected to match the filenames assigned to these files when they were saved to disk.
By default, embedded objects are saved in the same folder where the HTML file resides. To store related files in another folder, set msg.Parser.WorkingFolder property prior to calling any method which can save related files.
You can also tell MailBee to automatically save the message as HTML file to disk when the message gets parsed by setting msg.Parser.AutoSaveHtmlMode = HtmlMessageAutoSaving.SaveMessageHtmAndRelatedFiles (assuming msg is MailMessage instance). Another option is using GetHtmlAndSaveRelatedFiles method and its overloads.
If you're getting non-Latin characters not being displayed correctly in resulting HTML files, consider setting WriteUtf8ByteOrderMark to true (like in the sample code below).
// To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.Mime; // The actual code (put it into a method of your class). MailMessage msg = new MailMessage(); msg.LoadMessage(@"C:\Docs\TestMail.eml"); msg.Parser.WriteUtf8ByteOrderMark = true; msg.SaveHtmlAndRelatedFiles(@"C:\Temp\doc.htm");