MailMessageSaveHtmlAndRelatedFiles Method
Saves the HTML body of the message and all inline pictures and other inline objects to disk.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public bool SaveHtmlAndRelatedFiles(
	string filename
)

Parameters

filename
Type: SystemString
The HTML file to be written to.

Return Value

Type: Boolean
true if the body was successfully saved; otherwise, false.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionfilename is a null reference (Nothing in Visual Basic) or an empty string.
MailBeeIOExceptionAn I/O error occurred and ThrowExceptions is true.
Remarks

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.

Seting msg.Parser.WorkingFolder property value to some absolute path is mandatory in case if the HMTL in the e-mail message contains BASE tag (relative paths in URLs won't work correctly when BASE tag is present). Luckily, BASE tag is commonly not used in e-mail nowadays.

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).

Note Note
You may consider much simpler way of showing HTML e-mails with embedded images by direct base64 embedding of these images into the HTML. Use GetHtmlWithBase64EncodedRelatedFiles method for that. You can then save its result into an HTML file.
Examples
This sample loads the message from .EML file and generates HTML file containing the HTML body of this message.
// 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");
See Also