I need to retrieve a users’ calendar entries for a time period using Exchange Web Services.
I am using the calendar.FindAppointments API with a CalendarView.
When I use this api the items returned do not have all properties filled out (e.g. Body, Categories, and Attendees). Because of this I have to do the following:
CalendarFolder calendar = (CalendarFolder)Folder.Bind(this.Service, WellKnownFolderName.Calendar);
FindItemsResults<Appointment> findResults = calendar.FindAppointments(new CalendarView(startDate, endDate));
foreach (Appointment exAppt in findResults.Items)
{
Appointment a = Appointment.Bind(this.Service, exAppt.Id);
Models.Appointment appt = new Models.Appointment();
appt.End = a.End;
appt.Id = a.Id.ToString() ;
...
appt.Notes = a.Body;
...
}
Note the 2nd .Bind within the loop.
This REALLY makes querying slow (it’s already pretty horrible).
It takes MULTIPLE MINUTES to get about a dozen calendar entries!
I’ve looked but I can’t find anything that will let me batch retrieve “full” items. Is there something like that I haven’t found?
Maybe I’m doing something horribly wrong that is causing this performance?
I figured it out:
this.Service.LoadPropertiesForItems(findResults, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Id, ItemSchema.Body));But I still wish there were a way of specifying a
PropertySetwhen defining aCalendarViewas it would improve performance even further by reducing the number of round trips.