2013-10-14 38 views
1

我有一小段代码连接到Exchange以获取特定帐户的约会。此帐户没有邮箱。无法通过邮箱获取Exchange帐户的约会

Dim service As New ExchangeService(ExchangeVersion.Exchange2010_SP2) 
service.Credentials = New NetworkCredential("userID", "password") 
service.AutodiscoverUrl("[email protected]") 

Dim calView As New CalendarView(DateTime.Today, DateTime.Today.AddYears(2)) 
calView.Traversal = ItemTraversal.Shallow 
calView.PropertySet = New PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Subject, AppointmentSchema.Location) 

Dim mtgs As FindItemsResults(Of Item) = service.FindItems(WellKnownFolderName.Calendar, calView) 

该代码在最后一行提出以下例外。

当作为没有邮箱的帐户发出请求时,必须为任何独立文件夹ID指定邮箱主SMTP地址。

我已经使用service.UseDefaultCredentials = True代替了Credentials行来执行代码,并且它执行但当然会返回我的约会。有没有解决这个问题?我认为我的选择是说服Exchange管理员为感兴趣的账户授予我的账户模拟权限。

+0

考虑发布您的答案,作为答案。它会帮助其他用户。 – Idris

+0

谢谢,@颜色。 – Bashzilla

回答

1

我发现我的错误。此帐户对某些会议室的时间表拥有权限,但没有自己的邮箱(或日历)。因此FindItems行不应该使用“WellKnowFolderName.Calendar”,这将是该帐户的日历。相反,它应该使用新的FolderID对象来指定正在搜索的会议室的日历文件夹。

Dim _cal As New FolderId(WellKnownFolderName.Calendar, New Microsoft.Exchange.WebServices.Data.Mailbox(room)) 
相关问题