GetSearchFolders Method

Store.GetSearchFolders Method (Outlook)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Returns a Folders collection object that represents the search folders defined for the Store object.

expression .GetSearchFolders

expression A variable that represents a Store object.

Return Value

A Folders collection object that represents all the search folders for the Store object.

GetSearchFolders returns all the visible active search folders for the Store. It does not return uninitialized or aged out search folders.

GetSearchFolders returns a Folders collection object with Folders.Count equal zero (0) if no search folders have been defined for the Store.

For a Folders collection object that represents a collection of search folders, Folders.Parent returns the same object as Store.GetRootFolder. Folder.Folders returns Null (Nothing in Visual Basic).

The following code sample in Microsoft Visual Basic for Applications (VBA) enumerates the search folders on all stores for the current session.

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) 
End Sub


Other resources

© 2016 Microsoft