Class MhtSaveOptions
Contents
[
Hide
]MhtSaveOptions class
Provides options for controlling how MailMessage instances are saved to MHTML format. This class allows you to customize MHTML output formatting, attachment handling, header preservation, and resource rendering behavior when converting email messages to MHTML (MIME HTML) files.
public class MhtSaveOptions : HeadersFormattingOptions
Constructors
| Name | Description |
|---|---|
| MhtSaveOptions() | Initializes a new instance of the MhtSaveOptions class with the default options. |
Properties
| Name | Description |
|---|---|
| AfterHeadersFormat { get; set; } | Gets or sets the HTML written after the block of headers. |
| BeforeHeadersFormat { get; set; } | Gets or sets the HTML written before the block of headers. |
| CheckBodyContentEncoding { get; set; } | Gets or sets a value indicating whether the encoding of the HTML body is checked before saving. The default is false. |
| CssStyles { get; set; } | Gets or sets additional CSS styles added to the output. |
| CustomProgressHandler { get; set; } | Gets or sets a handler that is called as the saving progresses. |
| DefaultHeaderFormat { get; set; } | Gets or sets the HTML format of a header line, from which the template of each header in FormatTemplates is built; {0} stands for the name of the header. |
| DefaultPageHeaderFormat { get; set; } | Gets or sets the HTML format of the page header. |
| ExtractHTMLBodyResourcesAsAttachments { get; set; } | Gets or sets a value indicating whether the resources of the HTML body, such as images, are also written as attachments. The default is false. |
| FormatTemplates { get; } | Gets the formats of individual headers, keyed by the names in MhtTemplateName. |
| MailMessageSaveType { get; set; } | Gets or sets the format the options save to. |
| MhtFormatOptions { get; set; } | Gets or sets options for the MHTML output. The default is `MhtFormatOptions.WriteHeader |
| PreserveOriginalBoundaries { get; set; } | Gets or sets a value indicating whether the MIME boundaries of the original message are kept. The default is false. |
| PreserveOriginalDate { get; set; } | Gets or sets a value indicating whether the original date of the message is kept. The default is true. |
| RenderedContactFields { get; set; } | Gets or sets the groups of contact fields written for a contact. The default is ContactFieldsSet.AllExisting. |
| RenderingHeaders { get; } | Gets the headers written to the output, in order, as names from MhtTemplateName. By default: From, Sent, To, Cc, Bcc, Subject, Attachments, Importance and Categories. |
| SaveAllHeaders { get; set; } | Gets or sets a value indicating whether all headers of the message are written to the output. The default is false. |
| SaveAttachments { get; set; } | Gets or sets a value indicating whether the attachments are saved into the MHTML file. |
| SavedHeaders { get; } | Gets the headers of the message that are kept in the MIME headers of the MHTML file; the others are dropped. The list is empty by default. |
| SkipInlineImages { get; set; } | Gets or sets a value indicating whether inline images are left out of the output. The default is false. |
| Timeout { get; set; } | Gets or sets the time limit, in milliseconds, for formatting the message. The default is 3000 (3 seconds). |
Events
| Name | Description |
|---|---|
| event ResourceHtmlRendering | Occurs for each attachment rendered into the HTML; set the properties of the event arguments to supply the content, file or caption to use for it. |
| event TimeoutReached | Occurs when formatting the message takes longer than Timeout. |
Remarks
Use this class with Save to save messages in MHTML format. MHTML is a web page archive format that combines HTML content and embedded resources into a single file. The MhtFormatOptions property controls formatting options, SaveAttachments determines whether attachments are included, and SavedHeaders allows you to specify custom headers to include in the output.
Examples
The following example shows how to save MailMessage as MHTML.
[C#]
var eml = MailMessage.Load("Message.eml");
eml.Save("target.mthml", SaveOptions.DefaultMhtml);
[Visual Basic]
Dim eml = MailMessage.Load("Message.eml")
eml.Save("target.mthml", SaveOptions.DefaultMhtml)
See Also
- class HeadersFormattingOptions
- namespace Aspose.Email
- assembly Aspose.Email