Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Get info from second mailbox (Office 2003 / VB6)

    I have two mailboxes connected to my Outlook 2003. I use code like the sample below to access emails, this only processes emails in my first Mailbox, what do I change to get access to the emails in my second Inbox? I'm sure it should be something in the "Set MyInbox=" statement... but how and what?

    <pre>Sub Main()
    Dim olApp As Outlook.Application
    Set olApp = New Outlook.Application
    Dim objNS As NameSpace
    Dim myInbox As MAPIFolder
    Set objNS = olApp.GetNamespace("MAPI")
    Set myInbox = objNS.GetDefaultFolder(6) '6 gets the InBox folder
    '
    Dim itms As Items, lngC As Long, Mx As Long
    Set itms = myInbox.Items
    Mx = itms.Count
    '
    For lngC = 1 To Mx
    With itms(lngC)
    Debug.Print .Subject
    End With
    Next
    Set itms = Nothing
    Set objNS = Nothing
    End Sub
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get info from second mailbox (Office 2003 / VB6)

    See Jefferson Scher's <post:=713,982>post 713,982</post:>.

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get info from second mailbox (Office 2003 / VB6)

    OK, that indeed gets me in the other Mailbox, but I'm at the top level there as it seems as the "itms.Count" returns zero. So I need to got into its InBox subfolder... how do I do that then?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get info from second mailbox (Office 2003 / VB6)

    Let's say that f is a top-level folder as in Jefferson's post. Its subfolders are returned by f.Folders. So you can use f.Folders(2) or f.Folders("Inbox").

    Note: if you refer to a subfolder by name, you must use the name in the local language, for example in Dutch f.Folders("Postvak IN").

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get info from second mailbox (Office 2003 / VB6)

    Ah, get it. So is there a fixed variable that always gets me the Inbox (nice to have, I can use "InBox")

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get info from second mailbox (Office 2003 / VB6)

    I don't think so, the standard folders in your default .pst (Inbox, Calendar, Tasks etc.) are the only "fixed" ones - they cannot be renamed, moved or deleted. Folders in other .pst files can be renamed, moved or deleted freely so there is no fixed way to refer to them.

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Get info from second mailbox (Office 2003 / VB

    You might try the EntryID of the Folder, as in ActiveExplorer.CurrentFolder.EntryID - I have a vague recollection that the EntryID of an Outlook Item survives renaming, and it may survive moving within the same PST; of course, it does not survive deletion! <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Once the ID is known, get the Item using the .GetItemFromID("ItemIDString", Optional "ItemStoreIDString") Method.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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