|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.|
To create and save an MSG file:
- Creates a new instance of the MailMessage class and set properties such as from, to, subject and body.
- Call the MapiMessage class' fromMailMessage() method which accepts object of the MailMessage.
- Use the fromMailMessage() method to convert the MailMessage into MapiMessage (MSG).
- Calls the MapiMessage.save() 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.
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.