Loading, Viewing and Parsing MSG file

This topic explains how to load a Microsoft Outlook Message file (*.msg). The MapiMessage class is used to load MSG files and provides several static loading functions for different scenarios. The following code snippet shows you how to load MSG files from file or from stream.

Loading MSG Files

The following code snippet shows you how to load MSG files.

The following code example shows how to use MailMessage to load a message in MSG format.


MailMessage eml = MailMessage.Load("message.msg");

It should be noted that a resulting message is converted to EML format, including embedded message attachments. Don’t use this loading method if you want to preserve some specific msg format properties of the original message.

To preserve the original format of embedded message attachments, use the msgLoadOptions.PreserveEmbeddedMessageFormat property.


MsgLoadOptions msgLoadOptions = new MsgLoadOptions();
msgLoadOptions.PreserveEmbeddedMessageFormat = true;
var msg = MailMessage.Load(stream, msgLoadOptions);

Loading from Stream

The following code snippet shows you how to load file from stream.

Converting EML to MSG preserving embedded EML format

EML files can be loaded into MapiMessage class by instantiating a MailMessage object and passing it to MapiMessage.FromMailMessage method. If the EML file contains embedded EML files, use MapiConversionOptions.PreserveEmbeddedMessageFormat to retain the format of embedded EML files. The below code snippet shows how to load EML files into MapiMessage while preserving the format of embedded EML files.