Get appointments from coworker via EWS only with “Free / Busy time, subject, location” permission level

后端 未结 2 757
死守一世寂寞
死守一世寂寞 2021-01-03 13:56

I would like to get all appointments which are in a certain date range from my coworker by his email. I can access his calendar through outlook. I only want to know if he ha

相关标签:
2条回答
  • 2021-01-03 14:18

    Doesn't your compiler throw an error on this line?

    FolderId cfolderid = new FolderId(WellKnownFolderName.Calendar, "coworker@mexample.com");
    

    It should be like this:

    FolderId cfolderid = new FolderId(WellKnownFolderName.Calendar, new Mailbox("coworker@mexample.com"));
    

    MSDN source

    Please also mind that by using only the CalendarView for your date range, you are wasting ressouces. Try using a SearchFilter instead or additionally.

    0 讨论(0)
  • 2021-01-03 14:30

    If this works with Reviewer permissions and not the Free/Busy setting I can only presume that you need Reviewer permission level to read the calendar.

    An alternative what to get the Free / Busy time would be to use ExchangeService.GetUserAvailability

    Please see the below resources:

    https://msdn.microsoft.com/en-us/library/office/dn643673(v=exchg.150).aspx https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.exchangeservice.getuseravailability(v=exchg.80).aspx

    Code from the above link incase the break in the future:

    // Create a collection of attendees. 
    List<AttendeeInfo> attendees = new List<AttendeeInfo>(); 
    
    attendees.Add(new AttendeeInfo() 
    { 
        SmtpAddress = "mack@contoso.com", 
        AttendeeType = MeetingAttendeeType.Organizer 
    }); 
    
    attendees.Add(new AttendeeInfo() 
    { 
        SmtpAddress = "sadie@contoso.com", 
        AttendeeType = MeetingAttendeeType.Required 
    }); 
    
    // Specify options to request free/busy information and suggested meeting times.
    AvailabilityOptions availabilityOptions = new AvailabilityOptions(); 
    availabilityOptions.GoodSuggestionThreshold = 49; 
    availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 0;
    availabilityOptions.MaximumSuggestionsPerDay = 2;
    // Note that 60 minutes is the default value for MeetingDuration, but setting it explicitly for demonstration purposes.
    availabilityOptions.MeetingDuration = 60; 
    availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Good; 
    availabilityOptions.DetailedSuggestionsWindow = new TimeWindow(DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));
    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); 
    
    0 讨论(0)
提交回复
热议问题