2012-01-31 54 views
16

我使用Outlook 2007 - 和有我的主郵箱:大吉,馬克獲取參考額外的收件箱

我還添加其他郵箱我的個人資料:採購,請求

兩個顯示爲頂層在Outlook文件夾:

郵箱 - 泰特,馬克> -Conversation歷史
-deleted項目
-Drafts
- 收件箱
-Junk電子郵件

郵箱 - 採購,請求
--Conversation歷史
--Deleted項目
--Drafts
--Inbox
--Junk電子郵件

我可以用得到我的默認收件箱中的引用(大吉,馬克):
Set Inbox = ns.GetDefaultFolder(olFolderInbox)

如何在「採購,請求」郵箱中獲得對收件箱的引用?

回答

16

像這樣的東西應該做的伎倆

Dim objNS As Outlook.NameSpace 
Dim objFolder As Outlook.MAPIFolder 
Set objNS = GetNamespace("MAPI") 
Set objFolder = objNS.Folders("Procurement, Request") 
Set objFolder = objFolder.Folders("Inbox") 

此連結handling different Inboxes一些有用的代碼 - 這可能是感興趣

+0

非常感謝您! :) – Mark 2012-01-31 09:51:23

+0

@MarkTait很高興能有所幫助:) – brettdj 2012-01-31 09:59:41

+0

只有當商店已被添加到curent配置文件時,此功能纔有效。 – 2017-10-12 16:09:52

3

使用Namespace.GetSharedDefaultFolder。即使郵箱未在當前配置文件中打開,它也可以工作。你還需要有打開郵箱的權利,並在過程中的問題訪問該文件夾:

Set vNamespace = Application.GetNamespace("MAPI") 
set vRecipient = vNamespace.CreateRecipient("Procurement, Request") 
if vRecipient.Resolve Then 
    set vFolder = vNamespace.GetSharedDefaultFolder(vRecipient, olFolderInbox) 
End If 

如果需要打開其他用戶的郵箱(其全部關閉文件夾),你可以使用Redemption及其RDOSession .GetSharedMailbox方法:

set Session = CreateObject("Redemption.RDOSession") 
Session.MAPIOBJECT = Application.Session.MAPIOBJECT 
set Store = Session.GetSharedMailbox("Procurement, Request") 
set vFolder = Store.GetDefaultFolder(olFolderInbox) 
MsgBox "The address of the mailbox owner: " & Store.Owner.Address 
5
Dim olNS As NameSpace 
Dim InputFolder As Outlook.MAPIFolder 
Set olNS = Outlook.Application.GetNamespace("MAPI") 

' Get reference to folder in users Mailbox for Input 
Set InputFolder = olNS.Folders("Procurement, Request").Folders("Inbox") 

' all the emails in the shared inbox are represented by: 
InputFolder.Items 
+0

請詳細說明此代碼如何回答問題。 – JAL 2016-02-26 17:23:25