Free Support Forum - aspose.com

Convert .msg to a pdf/a

Hi

Is it somehow possible to convert a .msg to pdf/a?

Thanks

Giuseppe

Hi Giuseppe,


Thank you for contacting support.

Aspose.Words for .NET provides the functionality to save the Mhtml file to Pdf/a format. Please check the below code snippet for your reference. Please note the sample source code first converts the message to Mhtml using Aspose.Email and then produce the final Pdf from Mhtml file by using Aspose.Words for .NET component.

C#

var message = MailMessage.Load(“Aspose-TestMail.msg”);
using (var stream = new System.IO.MemoryStream())
{
message.Save(stream, MailMessageSaveType.MHtmlFromat);
var word = new Aspose.Words.Document(stream);
var pdfSaveOptions = new Aspose.Words.Saving.PdfSaveOptions();
pdfSaveOptions.Compliance = Aspose.Words.Saving.PdfCompliance.PdfA1b;
word.Save(“output.pdf”, pdfSaveOptions);
}

Regards,

i am copying your code and i cant get Aspose Email to give me a Load option. has the commands changed?

Hi Brain,


Are you talking about MailMessage.Load? There is no change in commands and you can specify the message format as follow in the Load command:


var message = MailMessage.Load(“Aspose-TestMail.msg”, MessageFormat.Msg);

I would recommend you to please download and use the latest version of Aspose.Email for .NET 2.6.0 in your applications. Please feel free to write us back if your requirements are different than as I have explained. We'll provide you further assistance as soon as possible.