Setting time zone for appointment using EWS

I had an issue with creating appointments in Exchange using EWS. The appointment would create fine, the time would be correct, but the Time Zone set would be Monrovia, Rekiyavik (UMT).

After much searching on the internet, I finally found this article: http://msdn.microsoft.com/en-us/library/cc500306.aspx from which I used the helper method and the following code in my method that calls the EWS appointment creation code (sorry it’s VB but it is old code):

Dim lLocalTimeZone As New TimeZoneType()
lLocalTimeZone.BaseOffset = TimeSpanToXSDuration(TimeZone.CurrentTimeZone.GetUtcOffset(vStartTime))

If vStartTime.IsDaylightSavingTime Then
    lLocalTimeZone.TimeZoneName = TimeZone.CurrentTimeZone.DaylightName
Else
    lLocalTimeZone.TimeZoneName = TimeZone.CurrentTimeZone.StandardName
End If

appointment.MeetingTimeZone = lLocalTimeZone

Now both the time and the time zone are correctly set.

5. April 2011 23:20 by Cutty | Comments (0) | Permalink
Comments are closed

About the author

Tips and snippets of stuff that I have discovered in my daily battle to survive in the world of high technology.

Month List