Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Exchange Online EWS Only Returns Availability when MinimumSuggestionQuality is set to Poor - Why?

$
0
0

We are using impersonation to access mailboxes hosted in Office 365 using EWS but the app will only return available timeslots when the availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Poor. I've tried adjusting the availabilityOptions.GoodSuggestionThreshold to no avail. Beyond assigning the "ApplicationImpersonation" role to the account being used to access mailboxes, are there any other permissions, licenses, or attributes that need to be set in order to use EWS to query for free/busy time?  The code snippet is below.

---

        //Returns a list of TimeSuggestions for the specified user(email) and date.
        string MyUser = "o365test109@contoso.com";

        //LB Note: Pulled impersonation information from https://msdn.microsoft.com/en-us/library/office/dn722379(v=exchg.150).aspx#sectionSection1       
        service.Credentials = new NetworkCredential("acns_calendarapptest@contoso.com", "acns_calendarapptestpw");
        service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");

        //Changing MyUser to an invalid user (0365idontexist@contoso.com) or a valid user (o365test100) that the app doesn't
        //have impersonation rights to will throw an error stating as much
        service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.PrincipalName, MyUser);
       
        List<TimeSuggestion> suggestions = new List<TimeSuggestion>();

        //---------------------------------------------------------------------------------------------
        //LB Note: I pulled this example from https://msdn.microsoft.com/en-us/library/office/dn643673(v=exchg.150).aspx

        List<AttendeeInfo> attendees = new List<AttendeeInfo>();
        attendees.Add(new AttendeeInfo()
        {
            SmtpAddress = MyUser,
            AttendeeType = MeetingAttendeeType.Organizer
        });

        // Specify options to request free/busy information and suggested meeting times.
        AvailabilityOptions availabilityOptions = new AvailabilityOptions();
        availabilityOptions.GoodSuggestionThreshold = 10;
        availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 1;
        availabilityOptions.MaximumSuggestionsPerDay = 30;
        availabilityOptions.MeetingDuration = 60;
        // LB Note: Setting this to "Poor" was the only way I could get results to show. Not sure what's going on here.
        availabilityOptions.

        //Returns a list of TimeSuggestions for the specified user(email) and date.
        string MyUser = "o365test109@contoso.com";

        //LB Note: Pulled impersonation information from https://msdn.microsoft.com/en-us/library/office/dn722379(v=exchg.150).aspx#sectionSection1       
        service.Credentials = new NetworkCredential("acns_calendarapptest@contoso.com", "acns_calendarapptestpw");
        service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");

        //Changing MyUser to an invalid user (0365idontexist@contoso.com) or a valid user (o365test100) that the app doesn't
        //have impersonation rights to will throw an error stating as much
        service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.PrincipalName, MyUser);
       
        List<TimeSuggestion> suggestions = new List<TimeSuggestion>();

        //---------------------------------------------------------------------------------------------
        //LB Note: I pulled this example from https://msdn.microsoft.com/en-us/library/office/dn643673(v=exchg.150).aspx

        List<AttendeeInfo> attendees = new List<AttendeeInfo>();
        attendees.Add(new AttendeeInfo()
        {
            SmtpAddress = MyUser,
            AttendeeType = MeetingAttendeeType.Organizer
        });

        // Specify options to request free/busy information and suggested meeting times.
        AvailabilityOptions availabilityOptions = new AvailabilityOptions();
        availabilityOptions.GoodSuggestionThreshold = 10;
        availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 1;
        availabilityOptions.MaximumSuggestionsPerDay = 30;
        availabilityOptions.MeetingDuration = 60;
        // LB Note: Setting this to "Poor" was the only way I could get results to show. Not sure what's going on here.
        availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Poor;
        availabilityOptions.DetailedSuggestionsWindow = new TimeWindow(Convert.ToDateTime("4/1/2015"), Convert.ToDateTime("4/2/2015"));
        availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;
 
        // Return free/busy information and a set of suggested meeting times.
        // This method results in a GetUserAvailabilityRequest call to EWS.
        GetUserAvailabilityResults results = service.GetUserAvailability(attendees,
                                                                    availabilityOptions.DetailedSuggestionsWindow,
                                                                    AvailabilityData.FreeBusyAndSuggestions,
                                                                    availabilityOptions);

= SuggestionQuality.Poor;
        availabilityOptions.DetailedSuggestionsWindow = new TimeWindow(Convert.ToDateTime("4/1/2015"), Convert.ToDateTime("4/2/2015"));
        availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;
 
        // Return free/busy information and a set of suggested meeting times.
        // This method results in a GetUserAvailabilityRequest call to EWS.
        GetUserAvailabilityResults results = service.GetUserAvailability(attendees,
                                                                    availabilityOptions.DetailedSuggestionsWindow,
                                                                    AvailabilityData.FreeBusyAndSuggestions,
                                                                    availabilityOptions);


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>