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

Free Support Forum - aspose.com

Subject have Chinese character not coming properly while creating appointment

Hello Team,


I’ve been using Aspose.Email for creating Appointment in PST(Microsoft Outlook) file.

Subject has non-english character are not coming properly .

please refer the following code :

// MapiProperty Subject = new MapiProperty(MapiPropertyTag.PR_SUBJECT, en.GetBytes(“在我睡觉之前,在我睡觉之前和里程前 chinese subject and body”));

Appointment f_objAppointment = new Appointment("", “在我睡觉之前,在我睡觉之前和里程前 chinese subject and body”, “”, DateTime.Now,
DateTime.Now, null,
null);

MailMessage f_objMsg = new MailMessage();
// f_objMsg.SubjectEncoding = UnicodeEncoding.Unicode;
// f_objMsg.PreferredTextEncoding = UnicodeEncoding.Unicode;
f_objMsg.AddAlternateView(f_objAppointment.RequestApointment());

f_objMsg.Subject = “在我睡觉之前,在我睡觉之前和里程前 chinese subject and body”;
//Till here subject is coming fine, but as soon as when we convert MailMessage to Mapi Message the subject gets changed in ???

MapiMessage f_objMapiMsg = MapiMessage.FromMailMessage(f_objMsg);
f_objMapiMsg.Subject = “在我睡觉之前,在我睡觉之前和里程前 chinese subject and body”;


MapiCalendar f_MapiCalendarObj = (MapiCalendar)f_objMapiMsg.ToMapiMessageItem();
Console.WriteLine(f_MapiCalendarObj.Subject);

i tried every thing even setting subject encoding too,still no result, I’ve been using Aspose.Email 6.4
and also testing on your latest version too.

I cannot upgrade the version from 6.4 to 17.5, hope you can understand is there any work-around you might suggest in 6.4 so that the issue can be solved.

I’ve also attached the code.

Looking for positive response.

Thank You.

Regards.
Amit
Hi Amit,

Thank you for your inquiry and sharing sample.

You have to set the format option before converting MailMessage to MapiMessage. Sample code snippet is given below for your reference. Please amend the code accordingly and give it a try. Feel free to contact us in case of any query or comments.

It is always recommended to use latest version of the APIs as the latest version contains fixes and new features. Furthermore we do not support bug fixes and enhancements in the old versions of the API.

CODE:
Aspose.Email.Calendar.Appointment f_objAppointment =
new Aspose.Email.Calendar.Appointment("", "在我睡觉之前,在我睡觉之前和里程前 chinese subject and body", "", DateTime.Now,
DateTime.Now, null,
null);
Aspose.Email.MailMessage f_objMsg = new Aspose.Email.MailMessage();
f_objMsg.AddAlternateView(f_objAppointment.RequestApointment());
Aspose.Email.Mapi.MapiConversionOptions objO = new Aspose.Email.Mapi.MapiConversionOptions();
objO.Format = Aspose.Email.Mapi.OutlookMessageFormat.Unicode;
Aspose.Email.Mapi.MapiMessage f_objMapiMsg = Aspose.Email.Mapi.MapiMessage.FromMailMessage(f_objMsg, objO);
Aspose.Email.Mapi.MapiCalendar f_MapiCalendarObj = (Aspose.Email.Mapi.MapiCalendar)f_objMapiMsg.ToMapiMessageItem();
f_MapiCalendarObj.Save(@"test_MapiAppointment.msg", Aspose.Email.Calendar.AppointmentSaveFormat.Msg);