Class EmlLoadOptions

EmlLoadOptions class

Provides options for controlling how MailMessage instances are loaded from EML format. This class allows you to customize the loading behavior for specific EML features such as TNEF attachment handling and embedded message preservation.

public class EmlLoadOptions : LoadOptions

Constructors

NameDescription
EmlLoadOptions()Initializes a new instance of this class that can be used to loading MailMessage from Eml format.

Properties

NameDescription
MessageFormat { get; }Represents the mail message format.It can be in eml,msg or mhtml format. The default value is Eml.
PreferredTextEncoding { get; set; }Gets or sets preferred encoding for message. Forcibly sets the preferred encoding for message subject and body. The default value is null.
PreserveEmbeddedMessageFormat { get; set; }Gets or sets a value indicating whether it is necessary to preserve format of embedded message at loading. By default the value is false.
PreserveTnefAttachments { get; set; }Controls TNEF attachment loading behaviour. By default the value is false.
RemoveSignature { get; set; }Gets or sets a value indicating whether signature will be removed while loading.

Remarks

Use this class with Load to specify custom loading options. Inherits from LoadOptions and adds EML-specific configuration through properties like PreserveTnefAttachments.

Examples

The following example shows how to convert EML to MSG.

[C#]

// Initialize EmlLoadOptions
var emlLoadOptions = new EmlLoadOptions()
       {
               PreserveTnefAttachments = true,
               PreserveEmbeddedMessageFormat = true
       };

// Initialize MailMessage with EmlLoadOptions
using (MailMessage message = MailMessage.Load("TestEml.eml", emlLoadOptions))
{
	// Convert EML to MSG
	message.Save("output.msg", SaveOptions.DefaultMsg);
}

[Visual Basic]

' Initialize EmlLoadOptions
Dim emlLoadOptions = New EmlLoadOptions() With
{
             .PreserveTnefAttachments = True,
             .PreserveEmbeddedMessageFormat = True
       }

' Initialize MailMessage with EmlLoadOptions
Using message As MailMessage = MailMessage.Load("TestEml.eml", emlLoadOptions)
	' Convert EML to MSG
	message.Save("output.msg", SaveOptions.DefaultMsg)
End Using

See Also