Class MsgLoadOptions
Contents
[
Hide
]MsgLoadOptions class
Provides options for controlling how MailMessage instances are loaded from MSG format. This class allows you to customize the loading behavior for Outlook MSG files, including TNEF attachment handling, RTF body preservation, email address preservation, and timeout configuration.
public class MsgLoadOptions : LoadOptions
Constructors
| Name | Description |
|---|---|
| MsgLoadOptions() | Initializes a new instance of the MsgLoadOptions class with the default options. |
Properties
| Name | Description |
|---|---|
| DeferAttachmentContent { get; set; } | Gets or sets a value indicating whether attachment content is read on demand instead of being loaded into memory while the message is being loaded. The default value is false. |
| DeferralThreshold { get; set; } | Gets or sets the size, in bytes, from which DeferAttachmentContent applies; smaller attachments are always loaded at once. The default is 4096. |
| KeepOriginalEmailAddresses { get; set; } | Gets or sets a value indicating whether the sender and recipient addresses are taken from the transport headers of the message as they are. When false (the default), they are rebuilt from the MAPI properties of the message. |
| MessageFormat { get; } | Gets the format this options object loads, as determined by its class: EML, MSG, MHTML, HTML and so on. |
| PreferredTextEncoding { get; set; } | Gets or sets the encoding used for the subject and the body regardless of what the message declares. The default is null: the declared encoding is used. |
| PreserveEmbeddedMessageFormat { get; set; } | Gets or sets a value indicating whether embedded messages keep their original format (EML or MSG) when loaded. The default is false. |
| PreserveRtfContent { get; set; } | Gets or sets a value indicating whether the RTF body of the MSG file is kept in the loaded message. The default is false. |
| PreserveTnefAttachments { get; set; } | Gets or sets a value indicating whether a TNEF attachment (winmail.dat) is kept as it is instead of being decoded into its files. The default is false. |
| RemoveSignature { get; set; } | Gets or sets a value indicating whether the digital signature is removed from a signed message while it is loaded. |
| Timeout { get; set; } | Gets or sets the time limit, in milliseconds, for formatting the body during the conversion. The default is 3000 (3 seconds). |
Events
| Name | Description |
|---|---|
| event TimeoutReached | Occurs when formatting the body takes longer than Timeout. |
Remarks
Use this class with Load to load Outlook MSG files and control various loading options. MSG is the native format for Outlook messages and can contain various Outlook-specific features. The PreserveTnefAttachments property controls TNEF handling, PreserveRtfContent preserves RTF body formatting, and Timeout limits the conversion time.
Examples
The following example shows how to use MsgLoadOptions to load an Outlook MSG file with custom settings.
[C#]
// Create MSG load options with custom settings
var loadOptions = new MsgLoadOptions()
{
PreserveTnefAttachments = true,
PreserveRtfContent = true,
KeepOriginalEmailAddresses = true,
Timeout = 5000
};
// Handle timeout event
loadOptions.TimeoutReached += (sender, e) =>
{
Console.WriteLine("Message loading timed out");
};
// Load MSG file with custom options
using (MailMessage message = MailMessage.Load("message.msg", loadOptions))
{
// Convert to EML format
message.Save("output.eml", SaveOptions.DefaultEml);
}
[Visual Basic]
' Create MSG load options with custom settings
Dim loadOptions As New MsgLoadOptions() With {
.PreserveTnefAttachments = True,
.PreserveRtfContent = True,
.KeepOriginalEmailAddresses = True,
.Timeout = 5000
}
' Handle timeout event
AddHandler loadOptions.TimeoutReached, Sub(sender, e)
Console.WriteLine("Message loading timed out")
End Sub
' Load MSG file with custom options
Using message As MailMessage = MailMessage.Load("message.msg", loadOptions)
' Convert to EML format
message.Save("output.eml", SaveOptions.DefaultEml)
End Using
See Also
- class LoadOptions
- namespace Aspose.Email
- assembly Aspose.Email