Consulting

Results 1 to 2 of 2

Thread: Mailboxes and profiles

  1. #1
    VBAX Newbie
    Joined
    Aug 2011
    Posts
    5
    Location

    Question Mailboxes and profiles

    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

  2. #2
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    I have some code here that might be useful to you.

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

    [vba]
    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
    [/vba]

    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.
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •