Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reference to a second Outlook mailbox in VBA

Status
Not open for further replies.

tekvb1977

Technical User
Nov 16, 2005
46
US
I have the VB code that could reference to my default Inbox folder:

Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim myRecipient

Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)

I have another mailbox folder called secondMailBox. How Could I reference to the Inbox folder of my secondMailBox.

Any ideas/thoughts will be highly appreciated? Thanks

J





 

Well your secondMailBox folder resides within a default folder. Get that folder and then use the folders collections. From the help

Set myOlApp = CreateObject("Outlook.Application")
Set ns= myOlApp.GetNameSpace("MAPI")
Set InbxFolder = ns.GetDefaultFolder(olFolderInbox)
Set myInbxFolder = myFolder.Folders("secondMailBox")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top