Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Exchange.WebServices.Data.ServiceValidationException: The property RequiredAttendees can't be used in FindItem requests

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);
like image 331
Spencer H Avatar asked Jul 27 '16 18:07

Spencer H


1 Answers

The recipients are one of properties along with the body that isn't returned with the FindItems operation, you need to use a GetItem request to get those properties see https://msdn.microsoft.com/en-us/library/bb508824.aspx and https://blogs.msdn.microsoft.com/exchangedev/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services/

like image 153
Glen Scales Avatar answered Sep 29 '22 00:09

Glen Scales