No announcement yet.

2010 Outlook VBA - Accessing non-default folders

  • Filter
  • Time
  • Show
Clear All
new posts

  • 2010 Outlook VBA - Accessing non-default folders

    I have viewed many threads on this topic, but I just can't get this to
    work for me: Please note that the folder "USPS Compass JE" is on the same
    folder hierarchy level as Inbox

    Dim olapp As Outlook.Application
    Dim olNameSpace As Outlook.Namespace
    Dim olfolder As Outlook.MAPIFolder
    Set olapp = CreateObject("Outlook.Application")
    Set olNameSpace = olapp.GetNamespace("MAPI")
    Set olfolder = olNameSpace.Folders("USPS Compass JE")
    When I look at the folder's properties, it's location is:
    \\Mailbox - Pelkey, Brian

    When I step through the code, I get an error message for the last
    coded line that "An object cannot be found".

    I also have tried:

    Set olfolder = olNameSpace.Folders("Mailbox - Pelkey,Brian/USPS Compass JE")

    AND also the GETFOLDER method which didn't appear to be valid.

    Thanks for any informed help offered.


  • #2
    Re: 2010 Outlook VBA - Accessing non-default folders

    have you viewed all threads?

    this appears on the Dave's HowTo sticky (first thread in this forum) -


    • #3
      Re: 2010 Outlook VBA - Accessing non-default folders

      Thank you Greg! That appears to work, subject to testing by my internal customer, but I am confident she will have success also.

      I have searched for that answer on the web from many different perspectives, but never hit on an answer that was that closely related to my question.



      • #4

        Thank you Greg for the answer!

        To those who are going through hell knowing the answer is there but unable to locate.

        Here is a direct link:

        And here is a working code i used from that link:

        Public WithEvents FolderItems As Outlook.Items

        Public Sub Application_Startup()
        Set objInbox = Session.GetDefaultFolder(olFolderInbox)
        strFolderName = objInbox.Parent
        Set objMailbox = Session.Folders(strFolderName)
        Set objFolder = objMailbox.Folders("Archive")
        Set FolderItems = objFolder.Items
        End Sub

        Public Sub FolderItems_ItemAdd(ByVal Item As Object)
        On Error Resume Next
        If Item.UnRead Then
        Item.UnRead = False
        End If
        End Sub