Convert .msg via .mhtml to pdf

Hi,

I evaluate the Aspose-converter and try to convert .msg-files to pdf.
As proposed in the help-file I convert the msg-files to mhtml and then
via word-converter to pdf.
The problem is, that in my pdf-file, I do not see, just the message-text, but also
all of the html-tags (,
…).
How can I suppress the tags, so that I can simply view the text?

Any help appreciated.

best regards,
Oliver

Hi Oliver,


I am sorry but I could not reproduce this issue at my end. Could you please post a sample MSG file, for which the final PDF contains the HTML tags? I will check at my end.

Hi,

sure, here is the source for my conversion:
sInStream = ReadFile2Stream(sInFile);

Aspose.Network.Mail.MailMessage mail = Aspose.Network.Mail.MailMessage.Load(sInStream);
System.IO.MemoryStream mstream = new System.IO.MemoryStream();
mail.Save(mstream, MailMessageSaveType.MHtmlFromat);

MemoryStream ms = new MemoryStream();
Document document = new Document(mStream);
Aspose.Words.Saving.SaveOptions saveOptions = Aspose.Words.Saving.SaveOptions.CreateSaveOptions(sOutFileName);
saveOptions.PrettyFormat = true;
document.Save(ms, Aspose.Words.SaveFormat.Pdf);

FileStream fs = File.OpenWrite(sOutFileName);
ms.WriteTo(fs);
fs.Flush();
fs.Close();



And in the provided zip-file, you will find a sample msg-file and the resulting pdf.

thank you for your help!

best regards,
Oliver



Hi Oliver,


Thanks for posting the sample file and source. There is problem in the second line where you are loading the MSG file in an instance of MailMessage class. For loading MSG files, the file format must be specified in Load() method as follows:

Aspose.Network.Mail.MailMessage mail = Aspose.Network.Mail.MailMessage.Load(sInStream, MessageFormat.Msg);

The resulting PDF will look fine, if you specify the format like above.

thank you for the hint. It really looks fine now!

The problem is solved!

best regards,
Oliver