You can convert an Outlook message to PDF by using the collaboration of Aspose.Email and Aspose.Words for .NET components. Below is the sample source and attached are my input and output files for your reference.
C#
var message = Aspose.Email.Mail.MailMessage.Load(“sample.msg”); using (var msgStream = new MemoryStream())
{
message.Save(msgStream, Aspose.Email.Mail.MailMessageSaveType.MHtmlFromat);
msgStream.Position = 0;
var options = new Aspose.Words.LoadOptions();
options.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
var document = new Aspose.Words.Document(msgStream, options);
document.Save(“output.pdf”, new Aspose.Words.Saving.PdfSaveOptions());
}
I am afraid, at the moment you can not add regular attachments to the MHTML file produced by Aspose.Email for .NET component. I will check back with development team if we can add this feature to our roadmap.
Once Aspose.Email component provides the required implementation, you may have to check with the experts of Aspose.Words to know how they will handle the attachments (regular) in MHTML to PDF conversion process.
Aspose.Email can add linked Resources embedded in an email while converting to MHTML (later on used for conversion to PDF using Aspose.Words), but doesn’t support adding regular attachments to the MHTML during conversion. For example, if the html body contains a reference to some image, it will be saved to mhtml. But if this image is just a regular attachment, it won’t be added to the MHTMl, and hence won’t be part of the PDF as well.
Aspose.Email API doesn’t have the capability to process regular email attachments and make them part of the output MHTML file. Only inline contents can be made part of the output MHTML. Please feel free to write to us if you have further query about this requirement.