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).
Does this show you all the available Inboxes?
If so then
ns.Folders(i).Folders("Inbox")
will get you the Inbox for each mailbox.I guess this is an old one, but somebody might need it one day. Here is code to iterate all "Sent Mail" folders in Outlook. (I think this will only work for Outlook 2010 and newer).
Use Store.GetDefaultFolder instead of Namespace.GetDefaultFolder. Note that Store.GetDefaultFolder was added in Outlook 2010. In the earlier versions of Outlook use Extended MAPI (C++ or Delphi) or Redemption (RDOStore.GetDefaultFolder.
Maybe you have long given up on this question, but here goes...
I've had this same problem before and I solved it by adding the Outlook Account Management API. Unfortunately for you, this a c++ oriented API. (My addin was already developed in c++)
Furthermore, the OOM (Outlook Object Model) which VBA and the .NET addins use has poor (if any) support for multiple accounts. By adding to exchange accounts, you have essentially added multiple accounts to your profile.
So, You might have to go down a level, using MAPI with c++ and then hook in the Outlook Account Management API. It's a lot of work, but that's exactely what I did and it worked like a charm.
Also, here is an example: http://www.codeproject.com/KB/IP/IOlkAccountManager.aspx
To Go to Mapix library
Mapix library link as given below
Mapix library for C++/MFC
Note: This Library valid for Inbox emails in MS Outlook