Msg files

We have multi .msg files where the old Aspose.Network library would leave some of the mime-headers in the body when converting the Mhtml to render to image. We have moved up to the latest version and moved code to the new Aspose.Email namespace but this has made it worse. We now have approximately 60 extra pages of rubbish when rendered.


I can send over a sample .msg file but I cannot post it to this forum.

Hi Tim,


Thank you for your inquiry.

I believe you are using the Aspose.Words component in collaboration with Aspose.Email to get your final output image. Please use latest assemblies of both products to test your scenario [links shared above]. If your problem persists then I would request you to provide us a sample console application along with problematic messages for our review.

You can share any sensitive information via an email. Please click “Contact” button on this thread, then select “send babar.raza an email” and attach samples with your message. After sending an email, please inform us here via adding your comments.

Looking forward to your response.

Hi Babar,


I have sent over a sample project and mail for your investigation.

Many Thanks,

Tim

Hi Tim,


Thank you for sharing your sample application and message file.

You can avoid your said problem by omitting the second parameter (FileCompatibilityMode.PreserveTnefAttachments) from the MailMessage.Load method. Please check the modified source as below and give it a try at your end.

C#

Aspose.Email.Mail.MailMessage mail = Aspose.Email.Mail.MailMessage.Load(“problem.msg”);
using (MemoryStream ms = new MemoryStream())
{
mail.Save(ms, Aspose.Email.Mail.MailMessageSaveType.MHtmlFromat);
ms.Position = 0;
Aspose.Words.LoadOptions loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
Aspose.Words.Document doc = new Aspose.Words.Document(ms,loadOptions);
doc.Save(“output.doc”, Aspose.Words.SaveFormat.Doc);
Console.WriteLine(string.Format(“Mail has {0} pages”, doc.PageCount));
}