Results Collection

Microsoft Outlook Visual Basic

Results Collection

Results

Stores data and results returned by the Search object and the AdvancedSearch method. The Results object contains properties and methods that allow you to view and manipulate data. For example the GetNext , GetPrevious, GetFirst , and GetLast methods allow you to search through the results and view the data by field. The Sort method allows you to sort the data.

Using the Results Collection

Use the SearchObject.Results property to return a Results object. The following event procedure stores the results of a search in a variable named objRsts and displays the results of the search in the Immediate window.

Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)

    Dim objRsts As Outlook.Results
    MsgBox "The search " & SearchObject.Tag & _
        "has completed. The scope of the search was " & _
        SearchObject.Scope & "."
    Set objRsts = SearchObject.Results
    'Print out number in Results collection
    Debug.Print objRsts.Count
    'Print out each member of Results collection
    For Each Item In objRsts
        Debug.Print Item
    Next

End Sub