EML to image: Special characters are displayed correctly only in "evaluation mode"

Hi!

I have to deal with emails which contains special country specific characters. You can find one in the attached file. When converting such file to an image the result is different if I set the Aspose.Email.License or not. Here is the code I use:

Aspose.Words.License wordsLicense = new Aspose.Words.License();
wordsLicense.SetLicense(cAsposeTotalLicense);

var emailLicense = new Aspose.Email.License();
emailLicense.SetLicense(cAsposeTotalLicense);

Aspose.Words.Document doc;
var options = new MailMessageLoadOptions { MessageFormat = MessageFormat.Eml };
var message = MailMessage.Load(“test czs.eml”, options);
message.PreferredTextEncoding = Encoding.UTF8;

using (var mhtStream = new MemoryStream())
{
message.Save(mhtStream, MailMessageSaveType.MHtmlFormat, MailMessageSaveOptions.WriteHeaderToMht);
doc = new Aspose.Words.Document(mhtStream, new Aspose.Words.LoadOptions(Aspose.Words.LoadFormat.Mhtml, “”, “”));
}

var imageSaveOptions = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg);
imageSaveOptions.JpegQuality = 80;
imageSaveOptions.Resolution = 150;
imageSaveOptions.PageCount = 1;
imageSaveOptions.PageIndex = 0;
doc.Save(“test czs.jpg”, imageSaveOptions);

But only if I exclude these 2 lines:
var emailLicense = new Aspose.Email.License();
emailLicense.SetLicense(cAsposeTotalLicense);

the characters čšž are displayed correctly in the image file. Both output files are also included in the attached file.

Regards,
Dejan

Hi Dejan,


Thanks for your inquiry. The problem occurs because you’re specifying UTF8 encoding, and specifying ASCII encoding resolves this issue:

message.PreferredTextEncoding = Encoding.ASCII;

Please let us know if we can be of any further assistance.

Best regards,

Hi,

thanks for the solution. Now the characters are displayed correctly. Still curious why without the license worked fine also with UTF8 encoding.

Regards,
Dejan

Hi Dejan,

Can you please share which versions of Aspose.Email and Aspose.Words are you using?

Best Regards,

Aspose Email 4.2 and Aspose.Words 14.5.

Hi Dejan,

I have tested the scenario using Aspose.Email for .NET 4.2.0 and observed that special characters are rendered properly while license is implemented. However the special characters become garbled when license is disabled.

I have logged it as NETWORKNET-34383 in our issue tracking system for further investigation by our development team. Once there is any information available in this regard, we’ll update you here via this thread here.

We are sorry for the inconvenience caused to you.

Following is the code used for testing:

static void TestEmlToImg()
{
Aspose.Email.License license = new Aspose.Email.License();
license.SetLicense(“E:\Aspose.Total.Product.Family.lic”);
var options = new MailMessageLoadOptions { MessageFormat = MessageFormat.Eml };
var message = MailMessage.Load(@“D:\Aspose\Testing\test czs.eml”, options);
message.PreferredTextEncoding = Encoding.UTF8;
using (var mhtStream = new MemoryStream())
{
message.Save(@“D:\Aspose\Testing\WithoutLicense.mhtml”, MailMessageSaveType.MHtmlFormat, MailMessageSaveOptions.WriteHeaderToMht);
}
}