Store.GetSearchFolders method (Outlook)

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

Syntax

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.

Remarks

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).

Example

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

See also

Store Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.