We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Subject line encoding for double byte languages not working

I am using the aspose email.mail library and creating mail messages from scratch so that they can be sent out at a later time. I am able to create and drop the messages in a physical file folder as expected using .Save construct as expected. I am casting the message in the MailMessageSaveType.OutlookMessageFormat format resulting in a message that can be opened and adjusted as needed prior to sending the message. When I attempt to write a message in a format other that a single byte language, such as Simplied Chinese or Russian, the subject line does not seem to get encoded properly. I end up with Question marks in the subject line which is a symtom of wrong encoding in my experience. I have tried two different constructs of setting the encoding to the approriate code page and both fail. Example for Simplified Chinese below.

#1)

item.BodyEncoding = System.Text.Encoding.GetEncoding936);

item.SubjectEncoding = System.Text.Encoding.GetEncoding(936);

#2)

item.PreferredTextEncoding = System.Text.Encoding.GetEncoding(936)

Both constructs have the same result; the body is encoded correctly, but the subject is not.

Any thoughts?

The product version I am using is Aspose .Email for .Net 3.5 version 20125.03.23

I am working through the Visual Studio 2012 platform in C#

Hi Brian,


Thank you for using Aspose products.

Please try by saving the message to Outlook Unicode Format by explicitly specifying the MailMessageSaveType.OutlookMessageFormatUnicode as second parameter in Save method.

Below is source code example for your reference,
C#

var msg = new Aspose.Email.Mail.MailMessage();
msg.From = new Aspose.Email.Mail.MailAddress("sender@domain.com", “sender”);
msg.To = new Aspose.Email.Mail.MailAddress("recipient@domain.com", “recipient”);
msg.Subject = “Testing”;
msg.TextBody = “Tested with Aspose.Email for .NET v1.6.0”;
msg.Save(“message.msg”, MailMessageSaveType.OutlookMessageFormatUnicode);

That was it! Thank you!