EWS: Check if Calendar Appointment IsCancelled [closed]
According to the documentation of the property, it is a bool
type and not Nullable<bool>
so it should always return something.
The fact you're getting the This property was requested, but it wasn't returned by the server
message might suggest you're asking for an inappropriate property for the item returned (i.e asking for the isCancelled
property on an EmailMessage
type.
What I'd do is a simple sanity check and verify your list of returned items are all of type Appointment
and not something else.
You could try calling the FindAppointments
method of the ExchangeService
class which will look exclusively for items that are appointments, but I've personally had a few problems with that not returning exactly what I expected. What I ended up doing was calling FindItems<Appointment>(WellKnownFolderName.Calendar, new ItemView(1000))
and looping over those.
After a good amount of trial and error I discovered that you also need to request the AppointmentSchema.AppointmentState
property when you want the AppointmentSchema.IsCancelled
property.
Here is the code I have which works:
var calendarView = new CalendarView(startTime, endTime);
var folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox(room.Email.Address));
calendarView.PropertySet = new PropertySet(
// AppointmentState is required for IsCancelled to work
AppointmentSchema.AppointmentState,
AppointmentSchema.IsCancelled
);
var roomBookings = exchangeService.FindAppointments(folderId, calendarView);