OfficeDev / ews-java-api

A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
MIT License
869 stars 560 forks source link

How do i get Attendees and and appointment responsible for a meeting using getUserAvailability? #675

Open christofferlanghoff opened 6 years ago

christofferlanghoff commented 6 years ago

I am using the function getUserAvailability to get a total list of CalendarEvents for a list of emailboxes (Attendees).

My problem is that i can acces all the information i need, except the orgainzer and attendees for the calendarMeeting.

Is there any way i can acces the name and/or email of the organizer (most important) and the attendees for (less important)?

I am working with this example code, just with more mails added to the attendees array. https://github.com/OfficeDev/ews-java-api/wiki/Getting-Started-Guide#availability-service

davster commented 6 years ago

I am not sure of your full scenario, but you may want to consider using a CalendarView instead of GetUserAvailability.

https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-get-appointments-and-meetings-by-using-ews-in-exchange

christofferlanghoff commented 6 years ago

My scenario is: I have an infoscreen that shows appointments for more than one mailboxes (rooms).

For this i need to send an list of rooms (email addresses ). Example: List attendees = new ArrayList(); attendees.add("room1@domain.com"); attendees.add("room2@domain.com"); attendees.add("room4@domain.com"); attendees.add("User1@domain.com"); attendees.add("User2@domain.com"); attendees.add("Room5@domain.com"); attendees.add("Room6@domain.com"); attendees.add("room10@domain.com"); attendees.add("room11@domain.com"); attendees.add("room12@domain.com"); attendees.add("room13@domain.com"); attendees.add("room14@domain.com"); attendees.add("room15@domain.com"); attendees.add("room16@domain.com");

For each room i need to get the appointments within an timewindow that is the same for all rooms. The data i need for each appointment is:

The appointments should be returned in one gathered list (i have created an custom object to contain these data).

How do i achieve this using as few webservice calls as possible with this framework? Is getUserAvailability the best method to solve this problem? -> I cannot get the organizer using this method for appointments. Which approach is the best for this framework?

davster commented 6 years ago

You can call FindRooms to get a list of the rooms and then call FindItem with a CalendarView to fetch the details of each meeting on the rooms' calendar. Note that you must call with an account that has rights to see the room's calendar - remember, a room is just a mailbox and only those with rights to see meeting details can see them.

snboisen commented 6 years ago

But that would mean N+1 EWS calls for N rooms, right? That won't scale very well.

christofferlanghoff commented 6 years ago

To ask the question more generally: If a company have 100 to 500 rooms our goal is to get a total list of appointments/meetings for all of these rooms at once as fast as possible. Using this api what is the best solution for this issue that uses the least time to get a total list of appointments from a list of already known room addresses.

List attendees = new ArrayList(); attendees.add("room1@domain.com"); attendees.add("room2@domain.com"); attendees.add("room4@domain.com"); attendees.add("User1@domain.com"); attendees.add("User2@domain.com"); attendees.add("Room5@domain.com"); attendees.add("Room6@domain.com"); attendees.add("room10@domain.com"); attendees.add("room11@domain.com"); attendees.add("room12@domain.com"); attendees.add("room13@domain.com"); attendees.add("room14@domain.com"); attendees.add("room15@domain.com"); attendees.add("room16@domain.com");

I tried running through a list of email adresses in an array using impersonation for each mailbox. This gets the appointments for each mailbox in a given CalendarView. My results here is for 14 mailboxes it takes 19 seconds to get appointments for 7 days with a total of 92 appointments. This solution do not scale well with our goal.

Do you have any suggestions to solve this that do not use to many service calls.

davster commented 6 years ago

The details of calendar items such as organizer, attendee list, etc... are not made available via GetUserAvailability (only start/end/Location, but not Organizer). As such, the only way to get access to them is via a calendar view. But this is a per-mailbox operation, just like listing off the contents of the inbox. This requires the caller to have read access on the target mailbox. We do not provide APIs via EWS for doing operations across a number of different mailboxes - that typically needs to be orchestrated by the client. The closest thing that I could suggest is that given that EWS is a batch API, you could list off several different mailboxes in the RootFolders element of the FindItem call. Of course, that would mean that whatever account you impersonated would have to have rights to all of those mailboxes and while it would reduce the number of HTTP calls you make, they are still executed serially on the server side.