Getting a users availability RRS feed

  • Question

  • I'm using the EWS Managed API 2.0, and am trying to reproduce some existing functionality in our software that previously used Outlook automation. This used the Outlook recipient.FreeBusy function that for a given day, returned a string of 0s and 1s representing time periods (in our case the hours) of the day, with a 0 indicating that period was free, and a 1 indicating it was busy.

    To get the same functionality using EWS it looks like I need to use the GetUserAvailability function, but the MergedFreeBusyStatus collection (which looks the closest to what I want) is always 0. I do get back a calendar event indicating 'busy', so why is the MergedFreeBusyStatus collection empty? I understand I could cycle through the calendar events and work it out myself, but it just seems there could be a simpler way (unless I'm misunderstanding how this works).

    This is my test code

    AttendeeInfo[] attInfo = {new AttendeeInfo(smtpAddress, MeetingAttendeeType.Required, false)}; AvailabilityOptions myOptions = new AvailabilityOptions(); myOptions.MeetingDuration = 60; myOptions.MergedFreeBusyInterval = 60; myOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy; GetUserAvailabilityResults availResults = _service.GetUserAvailability(attInfo, new TimeWindow(startTime, endTime), AvailabilityData.FreeBusy, myOptions); foreach (AttendeeAvailability availability in availResults.AttendeesAvailability) { foreach (LegacyFreeBusyStatus stat in availability.MergedFreeBusyStatus) { // *** This never entered because collection empty

    } foreach (CalendarEvent calItem in availability.CalendarEvents) { // Do get back my 1 calendar event marked as busy LegacyFreeBusyStatus l = calItem.FreeBusyStatus; } }

    • Edited by RJP1973 Tuesday, August 20, 2013 10:23 AM tidy up code
    Tuesday, August 20, 2013 10:22 AM


  • In your request you have set

    myOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;

    Which means the Merge information won't be returned if you want both the Events and Merge information to be returned you would need to use

    myOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusyMerged;

    or DetailedMerged

    see which has a list of what is and isn't returned for each of the different levels.


    • Marked as answer by RJP1973 Wednesday, August 21, 2013 9:54 AM
    Wednesday, August 21, 2013 5:39 AM

All replies