Class MailConversionOptions
Contents
[
Hide
]MailConversionOptions class
Provides options for controlling how MapiMessage instances are converted to MailMessage objects. This class allows you to customize the conversion behavior for TNEF handling, embedded message format preservation, RTF content, and email address management.
public class MailConversionOptions
Constructors
| Name | Description |
|---|---|
| MailConversionOptions() | The default constructor. |
Properties
| Name | Description |
|---|---|
| ConvertAsTnef { get; set; } | Set to true to import the MapiMessage information into a MailMessage object with MapiMessage as TNEF attachment. |
| KeepOriginalEmailAddresses { get; set; } | Gets or sets a value indicating whether need keep original email address. |
| PreserveEmbeddedMessageFormat { get; set; } | Gets or sets a value indicating whether it is necessary to preserve MSG format of embedded message at converting to MailMessage. By default the value is false. |
| PreserveRtfContent { get; set; } | Gets or sets a value indicating whether need keep rtf body in MailMessage. |
| Timeout { get; set; } | Limits the time in milliseconds of formatting message while converting. Default value 3 sec. |
Events
| Name | Description |
|---|---|
| event TimeoutReached | Raised if timed out while converting to MailMessage. |
Remarks
Use this class with ToMailMessage to specify custom conversion options. The ConvertAsTnef property enables TNEF attachment preservation, PreserveEmbeddedMessageFormat maintains original embedded message formats, PreserveRtfContent retains RTF body formatting, and Timeout controls the conversion time limit.
Examples
The following example shows how to use MailConversionOptions to convert a MapiMessage to MailMessage with custom settings.
[C#]
// Load a MapiMessage from file
MapiMessage mapiMessage = MapiMessage.FromFile("message.msg");
// Create conversion options with custom settings
var conversionOptions = new MailConversionOptions()
{
ConvertAsTnef = true,
PreserveEmbeddedMessageFormat = true,
PreserveRtfContent = true,
KeepOriginalEmailAddresses = true,
Timeout = 5000
};
// Handle timeout event
conversionOptions.TimeoutReached += (sender, e) =>
{
Console.WriteLine("Conversion timed out");
};
// Convert MapiMessage to MailMessage with custom options
MailMessage mailMessage = mapiMessage.ToMailMessage(conversionOptions);
// Save as EML
mailMessage.Save("output.eml", SaveOptions.DefaultEml);
[Visual Basic]
' Load a MapiMessage from file
Dim mapiMessage As MapiMessage = MapiMessage.FromFile("message.msg")
' Create conversion options with custom settings
Dim conversionOptions As New MailConversionOptions() With {
.ConvertAsTnef = True,
.PreserveEmbeddedMessageFormat = True,
.PreserveRtfContent = True,
.KeepOriginalEmailAddresses = True,
.Timeout = 5000
}
' Handle timeout event
AddHandler conversionOptions.TimeoutReached, Sub(sender, e)
Console.WriteLine("Conversion timed out")
End Sub
' Convert MapiMessage to MailMessage with custom options
Dim mailMessage As MailMessage = mapiMessage.ToMailMessage(conversionOptions)
' Save as EML
mailMessage.Save("output.eml", SaveOptions.DefaultEml)
See Also
- namespace Aspose.Email.Mapi
- assembly Aspose.Email