Hi
I'm facing a problem when i'm creating my msg and my html from an eml. (see attachments)
The problem is that i'f you open the EML, you will see that the charset is
charset="Windows-1252"
The moment that I generate my MSG. My charset is still
{\*\htmltag241 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">}
And the moment that i generate the HTML still the charset is Windows-1252.
I think for the msg that's no problem because I can see the french characters.
But for the html you will see that the french carachters are strange.
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
Bellow you can see my code:
public static void ConvertEmlToMsg(string emlFilePath, out string msgFilePath)
{
var mailMessage = MailMessage.Load(emlFilePath, new EmlLoadOptions());
msgFilePath = FileUtility.GetTempFileName("msg");
mailMessage.PreferredTextEncoding = Encoding.UTF8;
mailMessage.Save(msgFilePath, Aspose.Email.Mail.SaveOptions.DefaultMsgUnicode);
}
public static string GetMailFile(string msgFilepath, out List<MailAttachment> attachments)
{
attachments = new List<MailAttachment>();
string result;
var tmpFileName = FileUtility.GetTempFileName("tmp");
// Try saving as HTML
try
{
var mailMessage = MailMessage.Load(msgFilepath, new MsgLoadOptions());
mailMessage.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
mailMessage.BodyEncoding = Encoding.UTF8;
mailMessage.PreferredTextEncoding = Encoding.UTF8;
HtmlSaveOptions options = Aspose.Email.Mail.SaveOptions.DefaultHtml;
mailMessage.IsBodyHtml = true;
//save the message headers to output HTML using the formatting options
options.HtmlFormatOptions = HtmlFormatOptions.WriteHeader | HtmlFormatOptions.WriteCompleteEmailAddress;
options.MailMessageSaveType = MailMessageSaveType.HtmlFormat;
options.CheckBodyContentEncoding = true;
SetFormatHeaderDate(mailMessage);
//First save the mail as a HTML
mailMessage.Save(tmpFileName, options);
}
catch
{
if (File.Exists(tmpFileName))
{
try { File.Delete(tmpFileName); }
catch { }
}
tmpFileName = null;
}
}