Hello Joao,
Thanks for considering Aspose.
Can you please save the mail contents into word document and share the files. In fact when you are calling the method to save word document contents into Intermediate XML having Aspose.Pdf format, you can use the same method to generate a Word file. This approach will help us in understanding the fact that either the email contents are properly being exported into Word file or the issue is occurring at Aspose.Pdf end, when generating the PDF file.
You can also refer to the following link for information on Saving Documents.
Hi,
Thanks for your detailed answer.
From your reply it seems that the issue is occurring when saving .msg file contents into word document. I believe our team of experts taking care of Aspose.Words would be in better position to answer this query. For your convenience, I am moving this thread to Aspose.Words forum.
Thanks for your request. It seems the problem occurs in your code, because you do not flush TextWriter. Please try using the following code:
MapiMessage msg = MapiMessage.FromFile(@"Test157\email2.msg");
using(MemoryStream rtfStream = new MemoryStream())
{
// Write RTF content to the stream
TextWriter tw = new StreamWriter(rtfStream);
tw.Write(msg.BodyRtf);
tw.Flush();
// Create Docuemnt from stream
Document doc = new Document(rtfStream);
// Save document as DOC and As PDF
doc.Save(@"Test157\out.doc");
doc.SaveToPdf(@"Test157\out.pdf");
}
This code works fine with both your documents.
In addition, currently Aspose.Words allows converting to PDF without using Aspose.Pdf. Please see the following links for more information: https://docs.aspose.com/words/net/convert-a-document-to-pdf/
So you can just try using this new method to convert your Word documents to PDF. This feature is available starting from Aspose.Words 6.0.0.
Best regards.
After your correction I can get the file “email2.msg” to work fine.
As for “email1.msg”, I no longer have an exception, but the output word document does not contain the image that was embedded in the e-mail. Is that something normal?