MailMessage.Load methodMhtSaveOptions for output customizationMailMessage.Save method to save the message in MHTML formatDocumentDocument.Save method with SaveFormat.Pdf as second parameterThe namespaces required for the following piece of code are Aspose.Email & Aspose.Words. You can get the respective assembly files from the downloads or fetch the whole package from NuGet.
OFT to PDF conversion can be done on different operating systems such as Windows, Linux or macOS while using platforms such as Windows Azure, Mono and Xamarin.
// load message with an instance of MailMessage
var mailMsg = Aspose.Email.MailMessage.Load("message.oft");
// create an instance of MhtSaveOptions for MTHML customization
var mhtSaveOptions = Aspose.Email.MhtSaveOptions.DefaultMhtml;
// set MhtSaveOptions to write headers with complete email addresses
mhtSaveOptions.MhtFormatOptions = Aspose.Email.MhtFormatOptions.WriteHeader | Aspose.Email.MhtFormatOptions.WriteCompleteEmailAddress;
// temporarily save the MTHML in MemoryStream
using (var stream = new System.IO.MemoryStream())
{
mailMsg.Save(stream, mhtSaveOptions);
// load the MHTML stream in an instance of Document
var doc = new Aspose.Words.Document(stream);
doc.Save("output.pdf");
}
// load the resultant PDF in default application
System.Diagnostics.Process.Start("output.pdf");
(Outlook Message Item File)
(Microsoft Outlook Email Format)
(Apple Mail File Format)
(Outlook Personal Storage)
OFT files are templates created with Microsoft Outlook. OFT are used to send emails with common information to save time. Such files can be generated by creating a new email, adding necessary information and then using the Save As Office Template (.oft) dropdown from Microsoft Outlook.
Read More