Exchange EWS:如何获取房间中的所有约会

问题描述:

我正在尝试通过Exchange EWS获取所有Exchange中的房间预约。Exchange EWS:如何获取房间中的所有约会

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); 
service.UseDefaultCredentials = true;    
service.AutodiscoverUrl("[email protected]", RedirectionUrlValidationCallback); 

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

System.Collections.ObjectModel.Collection<EmailAddress> rooms = service.GetRooms("[email protected]"); 

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))); 

如果我运行这段代码我得到一个错误信息,指出:

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

事实上,如果我告诉我这样一个会议室邮箱的所有文件夹的集合,还有它里面没有文件夹。

我在做什么错?互联网中的所有示例都与WellKnownFolderName.Calendar一起使用。

该错误通常表明您的凭据可以连接到Exchange,但您无权访问您尝试访问的日历,因此您需要使用Add-MailboxPermission或授予访问权限授予对邮箱的访问权限以使用日历文件夹添加-MailboxFolderPermissions

干杯 格伦

+0

但是当我在Outlook中打开日历具有相同的凭据,我没有问题访问它。我需要另外访问邮箱吗? – murratore 2014-10-08 07:52:18

+0

您是否尝试过使用service.credentials指定凭据?您可以使用EWSEditor访问房间邮箱http://ewseditor.codeplex.com/ – 2014-10-08 08:43:09

+1

为日历文件夹添加权限解决了问题。例如,要允许用户'readonly'在'room123'上查看日历约会: 'Add-MailboxFolderPermission -Identity [email protected]:\ Calendar -AccessRights Reviewer -User readonly @ test.example.com' – 2017-08-08 07:01:40