Incorrect text encoding when saving to MHTML with headers

We are attempting to save a .msg email to PDF using the recommended intermediate MHTML format in Aspose.Email 3.2.0, but the conversion from .msg to .mhtml incorrectly alters the text encoding of the message. See the attached sample message containing Cyrillic characters. Any attempt to include the message headers in the generated MHTML causes the body of the message to change to question marks.


Unit tests show that if you don’t write the header the text survives, but generating the header (and the text/html version) means the body will be altered. The first two tests fail, but the last passes:

[Fact]
public void Email_To_Mhtml_Encoding_Lost_On_Format()
{
using (var msg = MailMessage.Load(@".\AsposeTests\22473.msg", MessageFormat.Msg))
{
using (var ms = new MemoryStream())
{
var format = new MhtMessageFormatter
{
DateTimeFormat = “f”,
SaveAttachments = false
};

format.Format(msg);

msg.Save(ms, MessageFormat.Mht, MailMessageSaveOptions.None);
ms.Seek(0, SeekOrigin.Begin);

var doc = new Aspose.Words.Document(ms);
var docText = doc.ToString(SaveFormat.Text);

Assert.Contains(“Подскажите”, docText);
}
}

}

[Fact]
public void Email_To_Mhtml_Encoding_Lost()
{
using (var msg = MailMessage.Load(@".\AsposeTests\22473.msg", MessageFormat.Msg))
{
using (var ms = new MemoryStream())
{
msg.Save(ms, MessageFormat.Mht, MailMessageSaveOptions.WriteHeaderToMht);
ms.Seek(0, SeekOrigin.Begin);

var doc = new Aspose.Words.Document(ms);
var docText = doc.ToString(SaveFormat.Text);

Assert.Contains(“Подскажите”, docText);
}
}
}

[Fact]
public void Email_To_Mhtml_Encoding_Works_Without_Headers()
{
using (var msg = MailMessage.Load(@".\AsposeTests\22473.msg", MessageFormat.Msg))
{
using (var ms = new MemoryStream())
{
msg.Save(ms, MessageFormat.Mht, MailMessageSaveOptions.None);
ms.Seek(0, SeekOrigin.Begin);

var doc = new Aspose.Words.Document(ms);
var docText = doc.ToString(SaveFormat.Text);

Assert.Contains(“Подскажите”, docText);
}
}
}

Hi Barry,


We are sorry for the inconvenience caused to you.

I was able to observe the issue of garbled message contents in the converted MHTML file. However, at my end, it happens in all cases where the message header is included in the output or not. I have logged it in our bug tracking system as NETWORKNET-34044 for further consideration by development team and will write back here once there is some udpate available in this regard.

The issues you have found earlier (filed as NETWORKNET-34044) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.