Skip to content

Instantly share code, notes, and snippets.

@bschapendonk
Created January 17, 2017 09:17
Show Gist options
  • Save bschapendonk/fd80715a7875da4a7de94077baa75d07 to your computer and use it in GitHub Desktop.
Save bschapendonk/fd80715a7875da4a7de94077baa75d07 to your computer and use it in GitHub Desktop.
using Microsoft.Exchange.WebServices.Data;
using System;
namespace EWS_FindAppointments
{
class Program
{
static void Main(string[] args)
{
var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.Url = new Uri("https://<exchangeServer>/ews/exchange.asmx");
service.Credentials = new WebCredentials(@"<username>", "<password>");
var folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox("<meetingroom>"));
var calendar = CalendarFolder.Bind(service, folderId, new PropertySet());
var calendarView = new CalendarView(DateTime.Today, DateTime.Today.AddDays(3).AddTicks(-1), 10);
calendarView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
var appointments = calendar.FindAppointments(calendarView);
foreach (Appointment a in appointments)
{
Console.Write("Subject: " + a.Subject.ToString() + " ");
Console.Write("Start: " + a.Start.ToString() + " ");
Console.Write("End: " + a.End.ToString());
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment