Saving an Email as PDF
This article shows how to convert an email message to PDF using Aspose.Email. Aspose.Email for .NET deals with network protocols and Microsoft Outlook features, and can not handle direct conversion to PDF. To overcome this, the samples in this article use Aspose.Email to convert the email message to the MHTML stream and then use Aspose.Words for .NET to load the MHTML stream and then save it as PDF. An email message can contain attachments as well. Since each attachment can be of different media types, Aspose.Email ignores these attachments while converting to MHTML i.e. only inline images in a message will be part of MHTML and any regular attachments will be ignored.
Converting Email message to PDF
The following code shows converting email messages to PDF using Aspose.Email in combination with Aspose.Words for .NET. This involves the following steps:
- Load the email message using MailMessage
- Save the email message to MemoryStream as MHTML
- Load the stream using Aspose.Words
- Save the message as PDF
The source email message can be seen as follow:
The converted PDF is as shown in the following image:
The following code snippet shows you how to convert email messages to PDF.