Load and Save Email Messages Using Aspose.Email for C++
Aspose.Email for C++ provides flexible options to load, save, and convert email messages in multiple formats, including EML, MSG, MHTML, and HTML. You can also customize load and save options to handle encoding, attachments, and formatting requirements.
Load a Message with Customized Load Options
The MailMessage class can load messages from various formats such as EML, MSG, MHTML, and HTML using specialized load options. These options allow developers to specify encoding preferences, preserve attachments, and manage embedded resources.
The following C++ example demonstrates how to load email messages using different load options.
Save Email Messages in Different Formats
Aspose.Email for C++ enables the conversion of messages between formats such as EML, MSG, MHTML, and HTML. Developers can use the SaveOptions class hierarchy to specify advanced saving parameters, including encoding, TNEF attachments, and boundary preservation.
Available save options include:
EmlSaveOptionsMsgSaveOptionsMhtSaveOptionsHtmlSaveOptions
Save Email as EML
The following code snippet demonstrates how to load an EML message and saves it to the disc in the same format.
Preserve Original EML Boundaries
You can preserve the original MIME boundaries when saving an EML file.
Preserve TNEF Attachments in EML
The following code example demonstrates how to save an email while preserving TNEF (Transport Neutral Encapsulation Format) attachments.
Convert EML to MSG
You can easily convert an EML file to an Outlook MSG format. The following code snippet demonstrates how to load an EML message and convert it to MSG using the appropriate option from SaveOptions class.
Save as MHTML
The following example demonstrates how to load an EML message and save it as an MHTML file.
Export to MHT with Custom Time Zone
You can set a custom or system time zone for message date fields before exporting to MHT format. The MailMessage class provides the TimeZoneOffset property to set customized Timezone. The following code snippet shows you how to export an email to MHT with customized TimeZone.
Export Email to EML
The following example shows how to export an email to EML format: