Exchange EWS: How to Get All Meetings in a Room

I am trying to get all Room Assignments in Exchange via Exchange EWS.

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;            
service.AutodiscoverUrl("hans.muster@domain.com", RedirectionUrlValidationCallback);

// Return all the room lists in the organization. 
EmailAddressCollection roomLists = service.GetRoomLists();

System.Collections.ObjectModel.Collection<EmailAddress> rooms = service.GetRooms("ZimmerZuerich@domain.com");

EmailAddress roomAdress = rooms[31];

FolderId folderid = new FolderId(WellKnownFolderName.Calendar, new Mailbox(roomAdress.Address));
FindItemsResults<Appointment> aps = service.FindAppointments(folderid, new CalendarView(DateTime.Now, DateTime.Now.AddHours(24)));

      

If I run this code, I get the error:

{"The specified folder could not be found in the store."}.

      

Indeed, if I show me a collection of all the folders for such a room mailbox, it has no folders.

What am I doing wrong? All examples on the web work with WellKnownFolderName.Calendar.

+3


source to share


1 answer


This error usually indicates that your credentials are suitable for connecting to Exchange, but you do not have rights to the calendar you are trying to access, so you need to grant access to the mailbox using Add-MailboxPermission or grant access to Calendars using Add-MailboxFolderPermissions



Cheers Glen

+2


source







All Articles