访问组帐户C#Outlook中的文件夹

时间:2015-05-19 19:58:38

标签: c# vb.net c#-4.0 outlook-vba

我有一个与我的Outlook相关联的群组帐户。我想访问该组中的文件夹。我怎么能这样做?

小组电子邮件是mm@abc.com

我可以使用以下代码从常规帐户访问文件夹..

Dim otkApp As Outlook.Application = New Outlook.Application
Dim ns As Outlook.NameSpace = otkApp.GetNamespace("MAPI")
Dim otkInboxFolder As Outlook.MAPIFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Thread.Sleep(5000)

1 个答案:

答案 0 :(得分:0)

Outlook对象模型提供Namespace类的GetSharedDefaultFolder方法,该方法返回一个Folder对象,该对象表示指定用户的指定默认文件夹。

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("mm@abc.com") 
 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