MapiCalendar item does not save with correct start and end times

We are attempting to save a calendar item to a MSG file. We are able to save the item, but the start and end dates aren’t correct. I have attached a project to this post which demonstrates the problem.


The project loads an email from Xml (our code) into your MapiMessage object. It then casts the object to MapCalendar and prints out the start and end times to the console. At this point everything looks as it should and times are what we expect. We then call the MapiMessage’s Save method, which writes the email to a MSG file. When we then proceed to open the MSG file, we see that start and end times are off by several hours.

The attached image shows an example.

Hi,

Thank you for writing to Aspose support team.

I have tried your sample code without any change but could not observe any issue in the output appointment file. This seems to be some environment specific issue. You may please give it a try on some other system using latest version Aspose.Email for .NET 6.0.0 and share the feedback with us.

We’ve updated the earlier project we sent to Aspose Email.Net 6.0. The time displayed in the MSG file is slightly more accurate in that I understand where the value comes from. However, it is still not the value I am expecting.

As you can see in the original image I sent, the appointment is in GMT +8 (Beijing) and occurs between 10-10:30am on December 12.

<t:Start>2015-12-12T10:00:00.000+08:00</t:Start>

<t:End>2015-12-12T10:30:00.000+08:00</t:End>

I set the timezone on my local machine to match. When I run the application and print out the MapiCalendar start and end times, I see that they are correct (10 and 10:30am). I also modified the application to reload the MSG file after it is saved, and verified that the times in fact correct.

However, after opening the MSG file in Outlook 2010, I see that the recurrence is set to be between 2-2:30 am. That value is the GMT time of the meeting. It is not that value I’d expect to see with my local timezone set to be GMT +8.

I have provided the updated project, but really the only substantial change was updating the Aspose Library. I’ve also attached the MSG file (My_Appointment.msg) that I created so you can attempt to open that as well. You can find it in the attached zip file.

Is there any insight you can give as to why to force it to display the local time and not the GMT time?

Hi,

Aspose.Email displays time in Local time zone by default. Keeping in view this behavior, we can convert this local time to UTC using DateTime.ToUniversalTime().

Console.WriteLine("Start Date
(MSG) : " + c.StartDate + ", UTC = " +
c.StartDate.ToUniversalTime());

Console.WriteLine("End Date (MSG) : " + c.EndDate + ", UTC = " + c.EndDate.ToUniversalTime());

On the other hand Outlook displays time in UTC, which is beyond the control of Aspose.Email. You may please have a look on the following article to get more information on this.

Outlook’s Appointments and Time Zone 1

Please feel free to write us back if you have any other query in this regard.