locked
Retrieving start time zone for calendar appointment in C# with EWS RRS feed

  • Question

  • I have a problem using EWS 1.1 from C# to retrieve the start time zone property for a calendar appointment.

    I created a test appointment with Outlook 2010, and explicitly set the time zone to "India Standard Time" (I'm in GMT here). Outlook does the right thing, and shows the appointment 6.5 hours earlier than the time I define.

    Now I look at the item with some C# code using EWS 1.1. Here's the salient points of the code I use:

        m_ExchangeService = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
        m_TargetMailbox = new Mailbox(m_TargetMailboxAddress);

    connects to an Exchange service (we have Exchange 2010 SP1 RU4) and gives me a mailbox object. I bind to the calendar with:

        FolderId folderID = new FolderId(WellKnownFolderName.Calendar, m_TargetMailbox);
        CalendarFolder calendar = CalendarFolder.Bind(m_ExchangeService, folderID);

    I do:

        FindItemsResults<Appointment> findResults = calendar.FindAppointments(calendarView);

    to get the items I want, and then for each appointment item I do:

        appointment.Load();

    to retrieve all available properties.

    After that, I do lots of calls to TryGetProperty(), and I retrieve values for everything I query. All the multi-value properties are present, so I've actually performed the load.

    However, if I do:

        TimeZoneInfo tzInfo;
        appointment.TryGetProperty<TimeZoneInfo>(AppointmentSchema.StartTimeZone, out tzInfo);

    then tzInfo is invariably set to null.

    Looking with the Visual Studio debugger I can see that yes, the property StartTimeZone has been loaded; and yes, the value is null.

    When I look at the calendar appointment with MFCMapi, though, I can see that the item has a property PidLidAppointmentTimeZoneDefinitionStartDisplay (0x80980102).

    MFCMapi recognises the binary block as a "Time Zone Definition", and in there is the time zone string I'm expecting, "India Standard Time".

    So: what have I done wrong so that the StartTimeZone property is not giving me the time zone string?

    Does anyone have some code that works to share here?

    Thanks in advance

    Alan

                            
    Friday, March 2, 2012 10:48 AM