Mrogath_Development
Mrogath_Development

Reputation: 57

Java EWS Reading Outlook Appointments

I would like to read all appointments from one user between some dates. And get from them the information about what, from when till when, which color (category) it has, the state if out of office. I didn't found a sample which worked. Can you show me a sample for that.

I'm using win7 and EWS Java API 1.2 from MS

Upvotes: 1

Views: 1255

Answers (1)

user1017413
user1017413

Reputation: 2183

Use a CalendarView with a start and end date on the Calendar folder to get everything within a set date range. Place the properties you'd like in a PropertySet, set it in the CalendarView, and use ExchangeService.findAppointments() to get them:

CalendarView view = new CalendarView(startDate, endDate);
PropertySet p = new PropertySet(ItemSchema.Categories, AppointmentSchema.Start, 
    AppointmentSchema.End);
view.setPropertySet(p);
FindItemsResults<Appointment> find = service.findAppointments(
    WellKnownFolderName.Calendar, view);

Iterate through the FindItemsResults and get what you need. I'm not sure if it's necessary, but various operations won't always return the information you need even if you request it with the PropertySet. If that's the case, then you'll need to use Appointment.load(PropertySet) or ExchangeService.loadPropertiesForItems(Items, PropertySet) to get them. I'm not sure what you mean by out of office on the Appointment itself. Do you mean the status of the Appoinment? The state as in province? By out of office, do you mean outside of the office of the user or if the user has a status of "Out of Office" (aka OOF) when the Appointment is scheduled?

Upvotes: 1

Related Questions