0
votes

I am using the EWS Java api 2.0 to read appointments on a Calendar mailbox. It works fine but my problem is to filter the appointments by its subject description, which I am not succeeding. At the moment I am using CalendarView to retrieve the appointments, something like this:

CalendarFolder cf = CalendarFolder.bind(service, WellKnownFolderName.Calendar);
CalendarView view = new CalendarView(startDate, endDate);
FindItemsResults<Appointment> findResults3 = cf.findAppointments(view);

I know that the Item class provides a method which I can apply a search filter, but it does return occurrences of a recurring series.

Something like that:

ItemView itemView = new ItemView(50);
SearchFilter searchFilter = new SearchFilter.ContainsSubstring(ItemSchema.Subject, "OK");
FindItemsResults<Item> findResults = service.findItems(WellKnownFolderName.Calendar, searchFilter, itemView);

Does anyone have an idea how to fix that?

Thanks and regards

2

2 Answers

0
votes

After using FindItems you will get all the recurring masters, which represents the whole series. From masters you can get occurrences and exceptions:

Appointment occurrenceOrException = Appointment.BindToOccurrence(service, new ItemId(recurringMasterId), index);

with the above you can get occurrence/exception by index. Note that index starts from 1 and when index is out of range it will throw an exception.

This might help: https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/dd633700%28v%3dexchg.80%29

0
votes

Keep in mind that instances of a recurring appointment (even if they are exceptions) do not physically exist, so they cannot be possibly returned by FindItems().

What you probably want is the GetUserAvailability operation (exposed by the ExchangeService.GetUserAvailability Method ) in Detailed mode.