Encodingproblem in subject after converting eml to msg

Hi,

I'm currently evaluating aspose.network for .net for converting eml to msg.

I have encountered a problem with the subject of the mail, we here in sweden use iso-8859-1 in our subject if we add swedish letters, and in my tests those letters gets converted to ? in the subject. Same letters in the body looks as they should.

Is this related to me using a non licensed version where I get (Aspose.Network Evaluation) added to the subject, or is this a problem that I would get in the licensed version too?

/Regards Stefan

Hi Stefan,

This issue is not related to the license.

Could you please post a test eml file for our testing, which have iso-8859-1 encoding in the subject. You may zip and send it using the forum “contact” --> “send saqib.razzaq an email”.

Hi Stefan,

Thanks for sending the test eml file.

Please try to use the overloaded method of MapiMessage.FromMailMessage() method as follows:

MailMessage eml = MailMessage.Load(@"E:\Data\Aspose\temp\testcase.eml", MessageFormat.Eml);

MapiMessage msg = MapiMessage.FromMailMessage(eml, OutlookMessageFormat.Unicode);

In the second parameter, pass OutlookMessageFormat.Unicode.

Hi Saqib,

and thanks for your quick response! Unfortunatly your solution introduced another problem, attachments in the eml-file isn't accessible in the msg-file after using Unicode.

Can you help me with that too, or do I need to chose wich problem to live with?

I have added a zip-file with a eml-file that have attachments and swedish letters in the subject.

/Regards Stefan

Hi Stefan,

Thanks for considering Aspose.

We are looking into this issue and get back to you soon.

Hello, Stefan,

We are still working on this issue. I will get back to you once it is resolved.

Thanks for your patience.

Hi

We have exactly the same problem.
We use a licensed version of Aspose.Total with the newest version 4.6 of the Aspose.Network library.

Please provide us with a solution or a workaround.

thank you very much!
Christian Broennimann, Swisscom

Hello,

Thanks for considering Aspose.

We have fixed this issue. The bug is caused by the unicode filename not saved properly.

Please try the hotfix attached.

Hello,

Thank you very much for your quick response. Now it works for Body and Attachments, but not for the Mail-Subject. It seems that, the subject encoding has no effect.
There are still question marks in the mail subject which should be replaced by the corresponding Umlaute(char).

Aspose.Network.Mail.MailMessage mailMessage = Aspose.Network.Mail.MailMessage.Load(pathToEmptyTemplate, Aspose.Network.Mail.MessageFormat.Msg);

mailMessage.SubjectEncoding = System.Text.Encoding.Unicode;

Aspose.Network.Outlook.MapiMessage mapiMessage = Aspose.Network.Outlook.MapiMessage.FromMailMessage(mailMessage,Aspose.Network.Outlook.OutlookMessageFormat.Unicode);

I will be really glad if you could provide a solution for this problem.

Best Regards

Christian Brönnimann

iret:

Hello,

Thanks for considering Aspose.

We have fixed this issue. The bug is caused by the unicode filename not saved properly.

Please try the hotfix attached.

Hi,

I've just tested your hotfix without changing my existing code at all. The '?'-signs remained in the subject, and my swedish signs in the body where lost, so the problem isn't solved as far as I can see.

Best Regards, Stefan

Hello, Stefan,

Could you share me your code and your test eml file for our debugging?

Thanks,

Could you please try my test code as following? I used your eml for my testing, it is working.

[Test]
public void Attachment_Lost_Test()
{
MailMessage _mailMessage = MailMessage.Load(@"C:\Documents and Settings\kylehuan\Desktop\attachcase\attachcase.eml");


_mailMessage.Save(@"Attachment_Lost_Test.unicode.msg", MailMessageSaveType.OutlookMessageFormatUnicode);

}

Hi again,

I tried your code, and it works fine.

Problem is, I have this code in a webservice and I get the infile as a base64-string, hnadles it with a memorystream and returns a base64-string. (My code is attached below) Earlier today I didn't change my code to use OutlookMessageFormat.Unicode, but now with my code below I get a msg-file with correct subject and body, but the attachment is corrupted.

/Regards, Stefan

Private Function ConvertEmlToMsg(ByVal strBase64 As String) As String

Dim bArrIn() As Byte = Convert.FromBase64String(strBase64)

Dim inStream As Stream = New MemoryStream(bArrIn)

Dim license As Aspose.Network.License = New Aspose.Network.License

license.SetLicense("\\accesspath\Aspose.Network.lic")

Dim eml As MailMessage = MailMessage.Load(inStream, MessageFormat.Eml)

Dim msg As MapiMessage = MapiMessage.FromMailMessage(eml, OutlookMessageFormat.Unicode)

Dim outStream As New MemoryStream

msg.Save(outStream)

outStream.Position = 0

Dim bArrOut() As Byte

bArrOut = outStream.ToArray

Return Convert.ToBase64String(bArrOut)

End Function

Hi again,

There are still some problems.

If I use the format OutlookMessageFormat.Unicode, mail subject seems to be correct encoded. But after I send the mail, the recepient recieves it again in ASCII(not ascii chars as '?'). In Outlook "Sent" folder it is unicode, but in "Inbox" folder it is ASCII.

Second Problem is also very interesting, very similar to the first problem. I use mailMessage.htmlbody for mail body.

mailMessage.IsBodyHtml = true;

In draft mode is mail body encoded correctly(from html body). After I send the mail. Mail body is again mailtextbody and not html body.

Thanks for your support. I need urgent to solve this problems.

Christian Brönnimann, Swisscom

Hi,

Please try the latest version of Aspose.Network from http://www.aspose.com/community/files/51/.net-components/aspose.network-for-.net/default.aspx . It should open the converted msg with correct attachments and send the original characters when you send the email via SmtpClient.