如何获取Outlook共享日历所有者的电子邮件

时间:2019-11-08 13:44:49

标签: c# outlook interop

我正在使用Interop API从Outlook的共享日历中获取约会。只有事先知道共享日历的所有者的电子邮件,我才能这样做。

在循环约会到共享日历中之前,我希望能够获取每个共享日历的所有者电子邮件。每个贡献都受到赞赏。

1 个答案:

答案 0 :(得分:1)

要获取共享日历文件夹,您需要使用Namespace类的GetSharedDefaultFolder方法,该方法返回一个Folder对象,该对象代表指定用户的指定默认文件夹。在委派方案中使用此方法,在该方案中,一个用户已将其一个或多个默认文件夹(例如,他们的共享Calendar文件夹)委派给另一用户。例如:

Sub ResolveName()  
 Dim myNamespace As Outlook.NameSpace  
 Dim myRecipient As Outlook.Recipient  
 Dim CalendarFolder As Outlook.Folder 
 Set myNamespace = Application.GetNamespace("MAPI")  
 Set myRecipient = myNamespace.CreateRecipient("Eugene Astafiev")  
 myRecipient.Resolve  
 If myRecipient.Resolved Then  
 Call ShowCalendar(myNamespace, myRecipient)  
 End If  
End Sub 

Sub ShowCalendar(myNamespace, myRecipient)  
 Dim CalendarFolder As Outlook.Folder 
 Set CalendarFolder = _  
 myNamespace.GetSharedDefaultFolder _  
 (myRecipient, olFolderCalendar)  
 CalendarFolder.Display  
End Sub

Outlook对象模型不提供任何用于获取共享文件夹列表的功能。最好的办法是遍历通讯录条目并尝试访问共享文件夹。