Outlook 2010 FASTEST METHOD TO ENUMERATE FOLDERS

oliv-

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
For Outlook 2016 using a For i= loop is faster than For Each. I haven´t tested that in earlier versions. And for Outlook 2010 and older (not sure about 2013) using the RDOFolder object from Dmitry´s Redemption is way faster than the OOM.
 
Top