public List <OutlookAppointment> GetCalendarEntriesInRange() { List <OutlookAppointment> appointments = new List <OutlookAppointment>(); var service = new Microsoft.Exchange.WebServices.Data.ExchangeService(Microsoft.Exchange.WebServices.Data.ExchangeVersion.Exchange2010_SP1); service.Credentials = new Microsoft.Exchange.WebServices.Data.WebCredentials(Settings.Instance.ExchageUser, Settings.Instance.ExchagePassword); if (string.IsNullOrWhiteSpace(Settings.Instance.ExchageServerAddress)) { service.AutodiscoverUrl(Settings.Instance.ExchageUser, ValidateRedirectionUrlCallback); } else { service.Url = new Uri(Settings.Instance.ExchageServerAddress + "/EWS/Exchange.asmx"); } DateTime min = DateTime.Now.AddDays(-Settings.Instance.DaysInThePast); DateTime max = DateTime.Now.AddDays(+Settings.Instance.DaysInTheFuture + 1); var calView = new Microsoft.Exchange.WebServices.Data.CalendarView(min, max); calView.PropertySet = new PropertySet( BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.IsRecurring, AppointmentSchema.AppointmentType, AppointmentSchema.End, AppointmentSchema.IsAllDayEvent, AppointmentSchema.Location, AppointmentSchema.Organizer, AppointmentSchema.ReminderMinutesBeforeStart, AppointmentSchema.IsReminderSet ); FindItemsResults <Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calView); foreach (Appointment appointment in findResults.Items) { OutlookAppointment newAppointment = GetOutlookAppointment(appointment, service); appointments.Add(newAppointment); } return(appointments); }
public List<OutlookAppointment> GetCalendarEntriesInRange() { List<OutlookAppointment> appointments = new List<OutlookAppointment>(); var service = new Microsoft.Exchange.WebServices.Data.ExchangeService(Microsoft.Exchange.WebServices.Data.ExchangeVersion.Exchange2010_SP1); service.Credentials = new Microsoft.Exchange.WebServices.Data.WebCredentials(Settings.Instance.ExchageUser, Settings.Instance.ExchagePassword); if (string.IsNullOrWhiteSpace(Settings.Instance.ExchageServerAddress)) { service.AutodiscoverUrl(Settings.Instance.ExchageUser, ValidateRedirectionUrlCallback); } else { service.Url = new Uri(Settings.Instance.ExchageServerAddress + "/EWS/Exchange.asmx"); } DateTime min = DateTime.Now.AddDays(-Settings.Instance.DaysInThePast); DateTime max = DateTime.Now.AddDays(+Settings.Instance.DaysInTheFuture + 1); var calView = new Microsoft.Exchange.WebServices.Data.CalendarView(min, max); calView.PropertySet = new PropertySet( BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.IsRecurring, AppointmentSchema.AppointmentType, AppointmentSchema.End, AppointmentSchema.IsAllDayEvent, AppointmentSchema.Location, AppointmentSchema.Organizer, AppointmentSchema.ReminderMinutesBeforeStart, AppointmentSchema.IsReminderSet ); FindItemsResults<Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calView); foreach (Appointment appointment in findResults.Items) { OutlookAppointment newAppointment = GetOutlookAppointment(appointment, service); appointments.Add(newAppointment); } return appointments; }