Creating and Saving Outlook Message (MSG) Files

Skip to end of metadata
Go to start of metadata
Contents Summary
Aspose.Email can create Outlook message (MSG) files. The MailMessage class has a save() method that can save the Outlook MSG file to disk or stream. The code snippet below creates an instance of the MailMessage class, and set properties like from, to, subject, body, before saving it.

Creating and Saving a MSG

To create and save an MSG file:

  1. Creates a new instance of the MailMessage class and set properties such as from, to, subject and body.
  2. Call the MapiMessage class' fromMailMessage() method which accepts object of the MailMessage.
  3. Use the fromMailMessage() method to convert the MailMessage into MapiMessage (MSG).
  4. Calls the method to save the MSG file.

If you open the saved file in Microsoft Outlook, it will look like the screenshot below.

Figure: The saved email message

Write the following code on the click event of the button control.

Implications of Body Compression

The RTF body compression method can be used to generate a smaller size MSG. However, this results in slower speed. To creating messages with improved speed, set the flag to false. This flag, in turn, has effect on the created PSTs: smaller MSG files results in smaller PST, and large MSG files returns in slower PST creation.

Smaller Size


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.