Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Chapel Hill, North Carolina, USA
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading Outlook mail (97-SR2)

    I have written VBA to read email from my Outlook inbox, but need to read from the inbox for a "secondary" mail folder. I.e. I use "File | Open | Other User's Folder.." to open the second folder which is used to receive email sent from a website -so it doesn't fill my mailbox up!

    How do I tell Access to look in the other folder?

    Thanks!

    Larry

  2. #2
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading Outlook mail (97-SR2)

    Try something like:

    <font face="Georgia"> Public Sub ListMessageSubjects()

    Dim appOutlook As Outlook.Application
    Dim objNameSpace As Object
    Dim objFolder As MAPIFolder
    Dim objMailItem As Object

    Set appOutlook = CreateObject("Outlook.Application")
    Set objNameSpace = appOutlook.GetNamespace("MAPI")

    Set objFolder = objNameSpace.Folders("Your Folder Name Here")

    For Each objMailItem in objFolder.Items

    Debug.Print objMailItem.Subject

    Next objMailItem

    appOutlook.Quit

    End Sub</font face=georgia>

    If you want to "drill down" into nested folders, then append <font face="Georgia">.Folders("Next level down folder name")</font face=georgia>; e.g.:

    <font face="Georgia"> Set objFolder = objNameSpace.Folders("Your Folder Name Here").Folders("Next level down folder name")</font face=georgia>

    Add more to drill further.

    Hope this helps a little.

    Tom

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Chapel Hill, North Carolina, USA
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading Outlook mail (97-SR2)

    Tom,

    Thanks for the help - this lets me reads from folders within my personal mailbox, using the syntax:

    Set objFolder = objNameSpace.Folders("Mailbox - My name").Folders("Next level down folder name")

    I still can't figure out the name of the "attached" folder. The folder says "Fire Drill - Inbox" , but I haven't found the right combination of folders and subfolder names to get it open. I'll check with our IT folks for suggestions. If you have any thoughts, I'd love to hear them.

    Thanks again

    Larry

  4. #4
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Richland, Washington, USA
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading Outlook mail (97-SR2)

    Larry,

    Rather than one-time opening the folder of interest (as you describe), add it "permanently" to your Outlook folder list. To do this (assuming you're using Microsoft Exchange Server), first select Tools | Services. Then select "Microsoft Exchange Server" and click the Properties button. Then click the Advanced Tab, then the Add... button and type in the mailbox name (e.g., "John Doe"). Click OK a few times to get out of all this. Now, you should have this mailbox listed in your folder list, in addition to your own mailbox.

    Once this is done (it becomes part of your profile so you won't have to do it again the next time you open Outlook), THEN you can use the VBA code I provided above (which, now that I better understand your problem, is probably similar to what you were already using to access your own mailbox):

    <font face="Georgia">Set objFolder = objNameSpace.Folders("Mailbox - John Doe").Folders("Inbox")</font face=georgia>

    or something similar.

    Does this get you closer?

    Tom

Posting Permissions

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