Results 1 to 8 of 8
  1. #1
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Folders or Messages (Outlook 2000)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> Loungers

    I got my hands on some Outlook VBA Code and I am dissecting it to learn about the Outlook Object Model.

    I have a couple of messages and some folders in my Inbox. I have, according to Outlook's Folder List 638 messages, and 53 folders.

    But when I do something like:

    Application.GetNamespace("MAPI").GetDefaultFolder( olFolderInbox).Items.Count I get 724? 638+53 = 691, so what are these 33 objects?

    But...

    Application.GetNamespace("MAPI").Folders.Count only yields 1, which I think is the InBox itself <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    Application.GetNamespace("MAPI").Folders("Personal Folders").Count generates an error, 438, Property/method not supported?

    Is there a way to find out the messages, and the folders and not have them lumped into one number?

    After the Inbox Folder, how do I get to a sub folder?

    TIA

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Folders or Messages (Outlook 2000)

    > Application.GetNamespace("MAPI").Folders.Count only yields 1, which I think is the InBox itself

    No, this collection contains your PSTs

    > Application.GetNamespace("MAPI").Folders("Personal Folders").Count generates an error, 438, Property/method not supported?

    Try Application.GetNamespace("MAPI").Folders("Personal Folders").Folders.Count

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Folders or Messages (Outlook 2000)

    Wassim,
    Regarding your mystery items, I believe these are hidden items that contain Views and Rules and possibly a few other things.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Folders or Messages (Outlook 2000)

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> Jefferson

    OK I reached that same point with the <<< Application.GetNamespace("MAPI").Folders("Personal Folders").Folders.Count >>> and looking at the OLH I also see that you do have an index of the Folders collection, but there are no good examples of how to loop, For-Each, and get to these folders.

    Since I don't know the names of these folders, I can't simply use their names to access them, so looking with the Index, or For-Each is prefered.

    So far, the code can work on all the messages in the InBox, but I do have these folders that are in the Inbox and they also contain messages that need to be processed. So how do I get access to these folders?

    Also, it seems that the For-Each loop goes by the date of the message, vs alphabetical, or any other way. Will this also be the case for the folders? I added the folders over a period of time, and I can see them listed alphabetically, and would like to process them this way if at all possible.

    TIA again...

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  5. #5
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Folders or Messages (Outlook 2000)

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> Rory

    OK, so we need to count these separately, and that is OK with me.

    But one extra question if you don't mind, the Outlook.pst file is the whole data file for Outlook, that is all the messages and attachments and rules and views, and contacts and calendar items are stored.

    But would that be equivalent programmatically that is to the NameSpace. That is the .PST file contains all, and the NameSpace contains all.

    TIA

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Folders or Messages (Outlook 2000)

    It's Folders(index).Folders(index) all the way down.

    To explore your inbox as Visual Basic sees it, do something like this:

    Sub ViewMyObjectProperties()
    Dim ns As Outlook.NameSpace
    Set ns = Application.GetNamespace("MAPI")
    Stop ' Now open the Locals window (View > Locals) and explore
    Set ns = Nothing
    End Sub

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

    Re: Folders or Messages (Outlook 2000)

    You can have several data files open in Outlook:
    - The standard data file.
    - The archive file if you turn on AutoArchiving.
    - Personal folders.
    - Other users' folders (when you're connected to an Exchange server.)
    So you can have many .pst files open, but they are all contained in the one NameSpace.

  8. #8
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Folders or Messages (Outlook 2000)

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> Jefferson

    I got it to work.

    Now I have:

    To Loop through all the folders in the InBox I am using <font color=blue>For lFolderCounter = 1 To oFolder.Folders.Count </font color=blue>

    and to loop through each of the messages in the folder, I use <font color=blue>For Each oMessage In oFolder.Folders(lFolderCounter).Items </font color=blue>where oFolder is

    Application.GetNamespace("MAPI").GetDefaultFolder (olFolderInbox)

    But I am wondering if this is going to work on the items in the InBox but not in folders?

    This Outlook object model is quite interesting, so I have learned a lot just by looking and doing this project.

    Thanks to all the members who helped.

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

Posting Permissions

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