How to: Enumerate Search Folders on All Stores
This topic describes a code sample that enumerates the search folders on all stores for the current session.
The code sample begins by getting all the stores for the current session using the NameSpace.Stores property of the current session, Application.Session.
For each store of this session, it uses Store.GetSearchFolders to obtain the collection of search folders for that store.
For each collection of search folders, it displays the name of each folder.
Remarks
To run this code sample, place the code in the built-in ThisOutlookSession module. Run the EnumerateSearchFoldersInStores procedure:
Sub EnumerateSearchFoldersInStores()
Dim colStores As Outlook.Stores
Dim oStore As Outlook.Store
Dim oSearchFolders As Outlook.folders
Dim oFolder As Outlook.Folder
On Error Resume Next
Set colStores = Application.Session.Stores
For Each oStore In colStores
Set oSearchFolders = oStore.GetSearchFolders
For Each oFolder In oSearchFolders
Debug.Print (oFolder.FolderPath)
Next
Next
End Sub