Share via


SearchSubFolders Property

Returns a Boolean indicating whether the scope of the specified search included the subfolders of any folders searched. This property is determined by the SearchSubfolders argument of the **AdvancedSearch**method and is specified when the search is initiated. Read-only.

expression.SearchSubFolders

*expression   * Required. An expression that returns a **Search**object.

Remarks

If True, the Search object searches through any subfolders in the specified filter path.

Example

The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example creates a Search object. The user's Inbox is specified as the scope of the search and the SearchSubFolders property is set to True. The event subroutine fires when the search has completed and displays the Tag and Scope properties for the new object as well as the results of the search.

Public blnSearchComp As Boolean

Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
    MsgBox "The AdvancedSearchComplete Event fired for " & SearchObject.Tag & " and the scope was " & SearchObject.Scope
    blnSearchComp = True
End Sub

Sub TestAdvancedSearchComplete()
    'List all items in the Inbox that do NOT have a flag:
    Dim objSch As Outlook.Search
    Const strF As String = "urn:schemas:httpmail:messageflag IS NULL"
    Const strS As String = "Inbox"
    Dim rsts As Outlook.Results
    Dim i As Integer
    blnSearchComp = False
    Const strF1 As String = "urn:schemas:mailheader:subject = 'Test'"
    Const strS1 As String = "Inbox"
    Set objSch = _
        Application.AdvancedSearch(Scope:=strS1, Filter:=strF1, SearchSubFolders:=True, Tag:="FlagSearch")
    While blnSearchComp = False
        DoEvents
    Wend
    Set rsts = objSch.Results
    For i = 1 To rsts.Count
        MsgBox rsts.Item(i).SenderName
    Next
End Sub

Applies to | Search Object

See Also | AdvancedSearch Method | AdvancedSearchComplete Event | AdvancedSearchStopped Event | Scope Property | Tag Property