PDA

View Full Version : Mailboxes and profiles



ideprize
08-14-2012, 06:16 PM
In my Outlook setup there are 2 mailboxes - I don't "log" into either one. They are both accessible equally in the left pane arranged in a vertical stack. The VBA app I have has an itemadd event and it only fires when the "top" and original mailbox is sent to. What I have gathered is I have to with the VBA code select the other mailbox's profile and thus its folder set. How do I select the profile of the second box? I tried making it the default mailbox but this did nothing for me. I realize this is a conceptual problem and I not seeing something architecturally so any insight into this "mailbox separation" would be greatly appreciated.

Respectfully,
Gordon Haas

JP2112
08-29-2012, 12:24 PM
I have some code here (http://www.jpsoftwaretech.com/handling-multiple-inboxes/) that might be useful to you.

Basically, you point the ItemAdd Event at each mailbox by walking the folder hierarchy.


Private WithEvents MyInbox As Outlook.Items
Private WithEvents MyOtherInbox As Outlook.Items

Private Sub Application_Startup()

Dim objNS As Outlook.NameSpace
Set objNS = GetNamespace("MAPI")

Set MyInbox = objNS.GetDefaultFolder(olFolderInbox).Items ' default Inbox
Set MyOtherInbox = objNS.Folders("Mailbox - Other Name"). _
Folders("Inbox").Items ' the "other" Inbox
End Sub


Change "Mailbox - Other Name" to the name that actually appears at the top of the folder hierarchy for that profile.

Now you can use MyInbox_ItemAdd to deal with incoming items in your Inbox, and MyProjectInbox_ItemAdd for incoming items in the other Inbox.