Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Inboxes from Outlook

I configured two Exchange accounts in Outlook 2010, however I cant find out how to get to Inbox of the second account. Session.GetDefaultFolder() always return the first one.

Even enumerating Session.Accounts, finding the right account and calling Session.Account(found one).Store.GetDefaultFolder() returns wrong Inbox (from the default exchange account, not the secondary).

like image 461
Ivan G. Avatar asked Jul 27 '11 18:07

Ivan G.


1 Answers

Does this show you all the available Inboxes?

Sub LoopThroughInboxes

Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim i As Long

Set ol = Outlook.Application
Set ns = ol.GetNamespace("MAPI")

For i = 1 To ns.Folders.Count
 Debug.Print ns.Folders(i).Name
Next i

If so then ns.Folders(i).Folders("Inbox") will get you the Inbox for each mailbox.

like image 69
JimmyPena Avatar answered Oct 29 '22 12:10

JimmyPena