Jaa


Getting time zone definitions by using the EWS Managed API 2.0

Last modified: October 13, 2012

Applies to: EWS Managed API | Exchange Server 2010

Note: This content applies to the EWS Managed API 2.0 and earlier versions. For the latest information about the EWS Managed API, see Web services in Exchange.

You can use the Microsoft .NET Framework 3.5 TimeZoneInfo class to get a list of the time zone definitions that are supported by the Exchange server.

To get the list of time zones that are supported by the Exchange server

  • Call the TimeZoneInfo.GetSystemTimeZones method. The following code shows how to iterate through the supported time zone definitions and write each definition's display name, ID, and Coordinated Universal Time (UTC) offset to the console.

    foreach (TimeZoneInfo tzinfo in TimeZoneInfo.GetSystemTimeZones())
    {
        Console.WriteLine(tzinfo.DisplayName + " | " + tzinfo.Id + " | " + tzinfo.BaseUtcOffset.ToString());
    }
    

The ability to access the supported time zone definitions is useful in many scenarios. For example, to set an appointment's StartTimeZone to Eastern Standard Time (EST) by using the TimeZoneInfo.FindSystemTimeZoneById method, you must supply the ID of the EST time zone. By examining the TimeZoneInfo objects that are returned by the TimeZoneInfo.GetSystemTimeZones method, you can determine that the ID of the EST time zone is Eastern Standard Time. The following code shows how to set an appointment's StartTimeZone to EST by supplying the ID of the EST time zone to the TimeZoneInfo.FindSystemTimeZoneById method.

appt.StartTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

Compiling the code

For information about compiling this code, see Getting started with the EWS Managed API 2.0.

Robust programming

  • Write appropriate error handling code for common search errors.

  • Review the client request XML that is sent to the Exchange server.

  • Review the server response XML that is sent from the Exchange server.

  • Set the service binding as shown in Setting the Exchange service URL by using the EWS Managed API 2.0. Do not hard code URLs because if mailboxes move, they might be serviced by a different Client Access server. If the client cannot connect to the service, retry setting the binding by using the AutodiscoverUrl(String) method.

  • Set the target Exchange Web Services schema version by setting the requestedServerVersion parameter of the ExchangeService constructor. For more information, see Versioning EWS requests by using the EWS Managed API 2.0.

Security

  • Use HTTP with SSL for all communication between client and server.

  • Always validate the server certificate that is used for establishing the SSL connections. For more information, see Validating X509 certificates by using the EWS Managed API 2.0.

  • Do not include user names and passwords in trace files.

  • Verify that Autodiscover lookups that use HTTP GET to find an endpoint always prompt for user confirmation; otherwise, they should be blocked.