using System.Collections.Generic;
using Microsoft.Exchange.WebServices.Data;
public static void Main()
var start = new DateTime(2016, 11, 28);
var end = new DateTime(2016, 12, 4);
string url = "https://outlook.office365.com/EWS/Exchange.asmx";
var emailaddressToGetAppointmentsFrom = "[your emailaddress here]";
var exchangeService = new Microsoft.Exchange.WebServices.Data.ExchangeService(ExchangeVersion.Exchange2010);
exchangeService.Url = new Uri(url);
exchangeService.Credentials = new WebCredentials("[your username]", "[your password]");
GetFromExchange(exchangeService, emailaddressToGetAppointmentsFrom, start, end);
public static void GetFromExchange(ExchangeService exchangeService, string emailAddress, DateTime start, DateTime end)
DateTime startUtc = start.Date.ToUniversalTime();
DateTime endUtc = end.Date.AddDays(1).ToUniversalTime();
var PidLidClipStart = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, 0x8235, MapiPropertyType.SystemTime);
var PidLidClipEnd = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, 0x8236, MapiPropertyType.SystemTime);
var filters = new List<SearchFilter>();
filters.Add(new SearchFilter.IsGreaterThanOrEqualTo(PidLidClipStart, startUtc));
filters.Add(new SearchFilter.IsLessThanOrEqualTo(PidLidClipEnd, endUtc));
var filterfull = new SearchFilter.SearchFilterCollection(LogicalOperator.And, filters);
var calendarFolder = new FolderId(WellKnownFolderName.Calendar, new Mailbox(emailAddress));
var view = new ItemView(1000);
view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.Subject);
var findResults = exchangeService.FindItems(calendarFolder, filterfull, view);
if (findResults.TotalCount > 0)
foreach (var item in findResults)
var appointment = (Appointment)item;
Console.WriteLine(string.Format("Found appointment {0}, with id: {1}", appointment.Id.UniqueId, appointment.Subject));