This sample shows you how to use the Exchange Web Services EWS Managed API to get calendar items in a recurring series programmatically.
A recurring series of appointments or meetings is made up of a recurring master, a number of occurrences in a series that repeat according to a set pattern, and, optionally, sets of occurrences that were changed and that were deleted.
How it works:
The following table summarizes the different methods to retrieve Appointment items from an Exchange calendar
|If you have the item ID for…||You can get…||By using the…|
|The recurring master calendar item||the first Occurence in the series||Appointment.FirstOccurrence|
|the last Occurence in the serie||Appointment.LastOccurrence property|
|The exceptions to the serie||Appointment.ModifiedOccurrences property|
|The deleted appointments of the serie||Appointment.DeletedOccurrences property|
|Any occurrence (given its index)||Appointment.BindToOccurrence method|
|A single occurrence in a series||The recurring master||Appointment.BindToRecurringMaster method|
|Any calendar item (an Appointment object)||The appointment type enumeration value||Appointment.AppointmentType property|
The following method GetRecurringSeriesItems accepts an instance of the ExchangeService class to connect to the Exchange Web Service.
In this method we find all the appointments in the calendar based on the dates set in the CalendarView. This will return the occurrences and exceptions to a recurring series and will return appointments that are not part of a recurring series. This will not return recurring master items.
Note that a search restriction or querystring cannot be used with a CalendarView.
To start using EWS Managed API, see this article: http://dotnet-practice.com/utiliser-exchange-web-service-ews-managed-api/
private static void GetRecurringSeriesItems(ExchangeService service)
// Specify a view that returns up to five recurring master items.
ItemView view = new ItemView(5);
// Specify a calendar view for returning instances of a recurring series.
DateTime startDate = new DateTime(2017, 6, 1);
DateTime endDate = new DateTime(2017, 7, 1);
CalendarView calView = new CalendarView(startDate, endDate);
FindItemsResults<Item> instanceResults = service.FindItems(WellKnownFolderName.Calendar, calView);
foreach (Item item in instanceResults.Items)
Appointment appointment = item as Appointment;
if (appointment.AppointmentType == AppointmentType.Occurrence)
Console.WriteLine("Appointment is a recurring occurrence.");
else if (appointment.AppointmentType == AppointmentType.Exception)
Console.WriteLine("Appointment is an exception occurrence.");
// Calendar item is not part of a recurring series.
// The value of appointment.AppointmentType is AppointmentType.Single.
Console.WriteLine("Appointment is not part of a recurring series.");
catch (Exception ex)
Console.WriteLine("Error: " + ex.Message);