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

Free Support Forum - aspose.com

Special characters issue in msg file

Hi,


We are facing issue with special characters in attachments in .msg file.
We are creating a .msg file using Aspose.Email which has attachments with special characters like Norwegian characters.
After the .msg file is created the attached file name is changed, but if we create an .eml file the attached file name is displayed correctly.
For this we have created a sample and attaching it with this thread.

Kindly provide us the solution for this.

Thanks & Regards,
Rahul Jain

Hi Rahul,

Thank you for using Aspose.Email.

Please use the OutlookMessageFormatUnicode while saving the message as shown in the following code sample and let us know if we can be of any additional help to you. Also, please download the latest version of Aspose.Email for .NET 4.1.0 to use in your applications.

Sample Code:

private static void SaveEmailMessage()

{

// The path to the documents directory.

string dataDir = Path.GetFullPath("../../../MsgFile/");

//Create an instance of the MailMessage class

MailMessage mail = new MailMessage();

mail.Attachments.Add(new Attachment(dataDir + "barcodeæâå.png"));

string directoryPath = string.Format("{0}_{1}_{2}_{3}_{4}", "EmlFile", DateTime.Now.Year, DateTime.Now.Month,

DateTime.Now.Day, DateTime.Now.Second);

if (!Directory.Exists(dataDir + directoryPath))

{

string new1 = dataDir + directoryPath;

Directory.CreateDirectory(new1);

}

mail.Save(dataDir + directoryPath + "\\EmbeddedImage.msg", MailMessageSaveType.OutlookMessageFormatUnicode);

Console.WriteLine("Message File downloaded to MsgFile Folder");

Console.ReadLine();

}