Hi team. Sorry I didn’t get back to you sooner.
I tested new Aspose.Email build (2.3.0). It works fine on code examples from the previous posts.
But I faced with another string encoding problem. I attached test project to work with. The problem is if I open .EML file, which contains Russian words in subject. As you can see in .EML file subject is in utf-8 encoding (see 1.png).
If I just send previously opened file via Aspose SmtpClient then message comes without changes (all Russian string are shown as expected). But if I add one code (assigns subject to itself), then message comes with an incorrect subject (please see 2.png).
I also tried to save file with different methods and flags (I mean MailMessageSaveType and MessageFormat) and then open it in outlook. Got the same issue. Only with MailMessageSaveType.OutlookMessageFormatUnicode I’ve got acceptable result, but still I cannot achieve the same during sending opened .EML file.
Important
FileCompatibilityMode.PreserveTnefAttachments is needed because of “winmail.data” attachment for outbound messages with appointment (see thread Broken appointment with attachments - Free Support Forum - aspose.com).
Complete code:
static void Main(string[] args)
{
SmtpClient _cl = new SmtpClient("host", 2526, "login", "password");
MailMessage _ms = MailMessage.Load("test.eml", FileCompatibilityMode.PreserveTnefAttachments);
_ms.Subject = _ms.Subject;
_cl.Send(_ms);
_ms.Save("test2.eml");
_ms.Save("test2_PreserveTnefAttachments.eml", FileCompatibilityMode.PreserveTnefAttachments);
_ms.Save("test2_EmlFormat.eml", MailMessageSaveType.EmlFormat);
_ms.Save("test2_Eml.eml", MessageFormat.Eml);
_ms.Save("test2_Msg.msg", MessageFormat.Msg);
_ms.Save("test2_OutlookMessageFormat.msg", MailMessageSaveType.OutlookMessageFormat);
_ms.Save("test2_OutlookMessageFormatUnicode.msg", MailMessageSaveType.OutlookMessageFormatUnicode);
}
Also I come up with a few questions:
- Is there any difference between following methods?
a. _ms.Save(“test2_EmlFormat.eml”, MailMessageSaveType.EmlFormat);
b. _ms.Save(“test2_Eml.eml”, MessageFormat.Eml);
- Is there any difference between following methods?
a. _ms.Save(“test2_Msg.msg”, MessageFormat.Msg);
b. _ms.Save(“test2_OutlookMessageFormat.msg”, MailMessageSaveType.OutlookMessageFormat);
Best regards,
Alex Shloma