EWS : How to access user’s free/busy info programmatically using Exchange Web Services (EWS)?

In this post, we will see how to access user free/busy information programmatically using Exchange Web Services (EWS) – Proxy. Exchange provides such a service by storing what is referred to as free/busy data. This information will indicate what requested time range is free, busy, and tentative for a particular user. It will also provide any out of office (oof) status as well. Free/Busy data can be obtained using the Availability service provided by the Exchange Server. This is simply a web service which obtains the free/busy data directly from a user’s calendar.

Specifically, the GetUserAvailability operation will provide the free/busy state at specific level of detail.Using GetUserAvailability operation, which provides current user availability information at a specified level of detail - about the availability of a set of users, rooms, and resources within a specified time period. Client applications such as Microsoft Office Outlook, Microsoft Outlook Web Access, Microsoft Outlook Mobile Access, and other applications use SMTP addresses to identify the requested user information.

Let start now by creating the binding, set the credentials/URL and pass the binding (esb) to the following functionality ( which I haven’t added here).

Identify the time to compare free/busy information:

Duration duration = new Duration();

duration.StartTime = DateTime.Now;

duration.EndTime = DateTime.Now.AddHours(4);

Identify the options for comparing free/busy information:

FreeBusyViewOptionsType fbViews = new FreeBusyViewOptionsType();

fbViews.TimeWindow = duration;

fbViews.RequestedView = FreeBusyViewType.MergedOnly;

fbViews.RequestedViewSpecified = true ;

fbViews.MergedFreeBusyIntervalInMinutes = 35;

fbViews.MergedFreeBusyIntervalInMinutesSpecified = true ;

Identify the user mailbox to review for free/busy data:
MailboxData[] mbx= newMailboxData[1];

mbx[0] = new MailboxData();

EmailAddress emailAddress = new EmailAddress();

emailAddress.Address = "user1@domain.com" ;

emailAddress.Name = String.Empty;

mbx[0].Email = emailAddress;

mbx[0].ExcludeConflicts = false
Make the request and set the time zone of the request:
getusrRequest.TimeZone = newSerializableTimeZone();

getusrRequest.TimeZone.Bias = 480;

getusrRequest.TimeZone.StandardTime = newSerializableTimeZoneTime();

getusrRequest.TimeZone.StandardTime.Bias = 0;

getusrRequest.TimeZone.StandardTime.DayOfWeek = DayOfWeekType.Sunday.ToString();

getusrRequest.TimeZone.StandardTime.DayOrder = 1;

getusrRequest.TimeZone.StandardTime.Month = 11;

getusrRequest.TimeZone.StandardTime.Time = "02:00:00" ;

getusrRequest.TimeZone.DaylightTime = new SerializableTimeZoneTime();

getusrRequest.TimeZone.DaylightTime.Bias = -60;

getusrRequest.TimeZone.DaylightTime.DayOfWeek = DayOfWeekType.Sunday.ToString();

getusrRequest.TimeZone.DaylightTime.DayOrder = 2;

getusrRequest.TimeZone.DaylightTime.Month = 3;

getusrRequest.TimeZone.DaylightTime.Time = "02:00:00" ;

In addition to that, add the mailbox and the view options to the request
getusrRequest.MailboxDataArray = mbx;

getusrRequest.FreeBusyViewOptions = fbViews;

Send the above request and get the response:
GetUserAvailabilityResponseType getusrResponse = esb.GetUserAvailability(getusrRequest);

Access the free/busy info:

if (getusrResponse.FreeBusyResponseArray.Length < 1)


Console.WriteLine ( "No free/busy response data available." );




foreach (FreeBusyResponseType fbrt in getusrResponse.FreeBusyResponseArray)


if (fbrt.ResponseMessage.ResponseClass == ResponseClassType.Error)


Console.WriteLine( "Error:" + fbrt.ResponseMessage.MessageText);




FreeBusyView fbv = fbrt.FreeBusyView;

Console.WriteLine(" Merged free/busy data: " + fbv.MergedFreeBusy);




If you run the above piece of code, then you will get the result:


For more information, you can refer the following article: http://msdn.microsoft.com/en-us/library/aa564001(v=exchg.140).aspx

Happy programming!!