5

I am attempting to query EWS with VB.Net, and I can retrieve most of the attributes for an appointment that I want however when I am attempting to retrieve the IsCancelled attribute the following exception is being encountered: This property was requested, but it wasn't returned by the server.

Is anyone able to advise if there are any problems with the IsCancelled attribute (ie is it always set to true or false)?

Our environment is a mixed one, EWS is running from Exchange 2007SP1, however we do have 2010 servers (about to embark on the upgrade in a month or so).

Can anyone point me to any resources on all attribute's available through EWS, the list is long and I am sure there are other usefull gems out there that I havent stumbled accross yet.

Any resources on tracking appointments in mailboxes setup as resources (using rooms in 2010, but not there yet), such as Cancelled and Updated meetings would be greatly appreciated.

Thanks,

Matt

Lima
  • 374
  • 3
  • 12
  • According to the docs, it should be either true/false. Are you sure the item is an `Appointment` type? It might explain the lack of that property if it is something else. – Ben Pilbrow Sep 05 '11 at 17:54
  • Ill check that out, I ended up having to bind to each item returned from the FindItems call which has helped somewhat. Are you able to provide a link to the docs? – Lima Sep 06 '11 at 00:31
  • I've added an answer for you. Additionally, this might be better over on Stack Overflow, however I'll let others decide its fate. – Ben Pilbrow Sep 06 '11 at 11:49

2 Answers2

3

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.

Ben Pilbrow
  • 12,041
  • 5
  • 36
  • 57
3

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);
Joey
  • 131
  • 2