I am accessing appointment attendees from an EWS Calendar. I tried:
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End);
But my appointments
list entries each returned null Required/Optional Attendees fields, even though the test appointments had been accepted by several users. My assumption is that the PropertySet needs to include more ApplicationSchema
properties like so:
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.RequiredAttendees,
AppointmentSchema.OptionalAttendees);
However this throws the following ServiceValidationException error on calendar.FindAppointments(cView):
Microsoft.Exchange.WebServices.Data.ServiceValidationException: The property RequiredAttendees can't be used in FindItem requests.
How do I fix this so that appointments
includes required/optional attendees?
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials(emailAddress, emailPassword);
// Initialize values for the start and end times, and the number of appointments to retrieve.
DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddYears(1);
const int NUM_APPTS = 4;
// Initialize the calendar folder object with only the folder ID.
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
// Set the start and end time and number of appointments to retrieve.
CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.RequiredAttendees,
AppointmentSchema.OptionalAttendees);
// Retrieve a collection of appointments by using the calendar view.
FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);