Use this code sample (along with the GetFolderPath function from Working with VBA and non-default Outlook Folders) to monitor a secondary Exchange mailbox that is open in a profile.
This code should also work to monitor any folder in another data file for new messages (not limited to Exchange accounts).
To use this code, macro security needs to be set to allow all macros or you will need to sign the code.
Paste the code into ThisOutlookSession, change the folder path you are monitoring (don't forget the GetFolderPath function) then click in the Application_Startup macro and click Run.
Option Explicit
Private objNS As Outlook.NameSpace
Private WithEvents objNewMailItems As Outlook.Items
Private Sub Application_Startup()
Dim objMyInbox As Outlook.MAPIFolder
' Use GetFolderPath function from
' http://slipstick.me/qf
Set objNewMailItems = GetFolderPath("Secondary Mailbox Name\Inbox").Items
Set objMyInbox = Nothing
End Sub
Private Sub objNewMailItems_ItemAdd(ByVal Item As Object)
'Ensure we are only working with e-mail items
'If Item.Class <> OlItemType.olMailItem Then Exit Sub
MsgBox "Message subject: " & Item.Subject & " received in Second Mailbox Name mailbox", vbCritical
End Sub

