Search code examples
timezoneexchangewebservicesexchange-server-2010

TimeZone and Working Hours for Users through EWS


Is it possible to get TimeZone and working hours of the users through EWS?

I am able to extract TZ and Working Hours for current user(Account with which the ExchangeService is initialized)

UserConfiguration usrConfig = UserConfiguration.Bind(service, "WorkHours", WellKnownFolderName.Calendar, UserConfigurationProperties.All);

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(new MemoryStream(usrConfig.XmlData));
XmlNodeList nlList = xmlDoc.GetElementsByTagName("WorkHoursVersion1");
Console.WriteLine(nlList.Item(0).InnerXml);
string str = nlList.Item(0).InnerXml;

But I am not able to extract the same information for other users.


Solution

  • I use the GetUserAvailability operation.

    Input is an array of users. Output includes an array of AttendeeAvailability, which contains a WorkingHours property, which itself includes TimeZone:

    GetUserAvailabilityResults uars = service.GetUserAvailability(
        new AttendeeInfo[] { new AttendeeInfo(smtpAddressOfUser, MeetingAttendeeType.Required, true), ... }, 
        new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)), 
        AvailabilityData.FreeBusy
        );