We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

MSG to PDF with attachment

Can we convert msg extension to pdf with attachment using your libraries?

@pmintersys,

Thank you for contacting Aspose support team.

Aspose.Email can be used to convert MSG to PDF. We need to set following flag for controlling the display of attachment as follows:

MhtSaveOptions.SaveAttachments = true

Above line will display names of all attachments in the header of PDF file. It will also render all the images in the attachments to the PDF. However no other attachment will be rendered in the PDF. Please give a try to the following sample code and share the feedback.

MailMessage theMessage = MailMessage.Load(@"Test Attachments.msg");
MhtSaveOptions opt = new MhtSaveOptions();
opt.SaveAttachments = true;
MemoryStream stream = new MemoryStream();
theMessage.Save(stream, opt);
stream.Seek(0, SeekOrigin.Begin);
Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
Aspose.Words.Document doc = new Aspose.Words.Document(stream, loadOptions);
Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
options.Compliance = PdfCompliance.Pdf15;
doc.Save(@"Test Attachments.msg.pdf", options);

sample.png (15.1 KB)