I am using MailMessage.Load() method to convert an .eml file to a Message. For some .eml files, the conversion is adding extra ?'s .
Has anyone ran into this and knows what could be causing this? Is there a workaround?
Below is a code snippet that I am using to repro the issue with the files that has this issue. Also note, I have tried with many different versions pf Aspose.Email, including the latest.
var file = new FileInfo(filename);
Console.WriteLine(file.Name);
MailMessage mailMessage = MailMessage.Load(file.FullName);
mailMessage.BodyEncoding = Encoding.UTF8;
Console.WriteLine(mailMessage.Body);
As a result of our investigation, we found out that this is not a problem with Aspose.Email, but a configuration of the console output.
The default console encoding is the same as in the operating system, so in some cases there can be problems.
You can force the console encoding by setting the Console.OutputEncoding property as follows:
var msg = MailMessage.Load("123.eml");
Console.OutputEncoding = Encoding.UTF8;
Console.WriteLine(msg.Body);