Hi,
Look at the email attached. If I want to open the HTMLBody of the email with Aspose.Words, I first need to decode the HTMLBody. Aspose.network email object have information about the body encoding. The property is
Message.BodyEncoding
If this property is null, there is another property witch is
Message.PreferredTextEncoding
.
So, to decode the body, here is what I do to find the correct encoder to use :
Encoding en = Encoding.Default;
if (email.Message.PreferredTextEncoding != null) { en = email.Message.PreferredTextEncoding; }
if (email.Message.BodyEncoding != null) { en = email.Message.BodyEncoding; }
byte[] html = en.GetBytes(email.Message.HtmlBody);
MemoryStream ms = new MemoryStream(html);
LoadOptions lo = new LoadOptions();
lo.LoadFormat =
LoadFormat.Html;
Document doc = new Document(ms, lo);
.
For the attached email : bodyencoding is null and preferedTextEncoding is the one detailed in the attached picture. But if I use the preferedTextEncoding then the docx file created with Aspose.Words contains stange characters.
So here is my question : how do I know witch encoding to use to get the correct text in Aspose.words?
Regards,