exchange EWS API find appointment by organizer and time frame

378 views Asked by At

Using EWS API, I'm able to find an appointment using time frame and a room's mailbox address like this:

public static Appointment GetAppointmentByMailboxAndTimeFrame(ExchangeService EWS,DateTime startDate, DateTime endDate , string mailbox)
    {
        Appointment apt=null;
        try
        {
            // Set the start and end time appointments to retrieve.
            CalendarView cView = new CalendarView(startDate, endDate);
            FolderId CalendarFolderId = new FolderId(WellKnownFolderName.Calendar, mailbox);
            EWS.ImpersonatedUserId = null;
            // Retrieve an appointments by using the calendar view.
            FindItemsResults<Appointment> appointments = EWS.FindAppointments(CalendarFolderId, cView);
            apt= appointments.First();
        }
        catch (Exception)
        {
           apt = null;
        }
        return apt;
    }

I'm wondering is there a way to get an appointment for organizer using organizer's email address and time frame? The purpose of this is only organizer is able to update the appointment, not the attendee(room is also attendee)

1

There are 1 answers

0
Glen Scales On

You can't combine a CalendarView with a SearchFilter so you can't do both in one operation. A CalendarView is necessary to expand recurring appointments so you generally are just better to restrict the property-set your returning as much as you can and then filter the appointment at the client side. (From a performance perspective this is generally quicker anyway).

Otherwise if you don't have any Recurring appointments that need expansion you could create a SearchFilter based on the individual properties.