• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Outlook 2010 FASTEST METHOD TO ENUMERATE FOLDERS

oliv-

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
#1
Hi,
Is there a faster method to enumerate all OUTLOOK FOLDERS and SUBFOLDERS ?
Perhaps DASL and Application.AdvancedSearch ?
I want to make a ".pickfolder" alternative.



Code:
Private Sub ListSubFolders()

    Dim OL As Outlook.Application
    Dim olNS As Outlook.NameSpace
    Dim objFolder As Outlook.Folders

    Set OL =Outlook.Application
    Set olNS = OL.GetNamespace("MAPI")

    Set objFolder = olNS.GetDefaultFolder(olFolderInbox).Parent
   call processFolder (objFolder)
End Sub


Sub ProcessFolder(StartFolder As Outlook.MAPIFolder)
    Dim objFolder As Outlook.MAPIFolder
    On Error Resume Next

    ' do something specific with this folder
    If StartFolder.DefaultItemType = olMailItem Then
     Debug.Print StartFolder.FolderPath
    End If
    ' process all the subfolders of this folder
    For Each objFolder In StartFolder.Folders
        Call ProcessFolder(objFolder)
    Next

    Set objFolder = Nothing
End Sub
 

Similar threads