Searching Items

Outlook Developer Reference

This topic describes the entry points to search items in folders and access search results.

Application.AdvancedSearch Explorer.Search Search.GetTable
Purpose Provides programmatic search on items in a specified folder based on a filter. Performs a programmatic content indexer search that is analogous to a user executing a search from the Outlook user interface. Provides an efficient way to access items (in a Table) returned by a prior Application.AdvancedSearch. This entry point does not carry out a separate search.
Scope of Search Folder specified as a search parameter. Determined by the parameter SearchAllItems. If SearchAllItems is True, the method will search across all folders that have the same folder type as the current folder (specified by the DefaultItemType property of Explorer.CurrentFolder) and all stores that have been selected for search in the Search Options dialog box. If SearchAllItems is False, the method will search only the folder represented by Explorer.CurrentFolder. Since the Search object is returned from a prior Application.AdvancedSearch operation, the scope of the search associated with Search.GetTable is that of the prior Application.AdvancedSearch.
Search Filter In DAV Searching and Locating (DASL) syntax. Any valid keywords that are supported by Outlook search in the user interface. Search phrases are delimited by double quotes and can be concatenated to form a single search filter string. Similar to the scope, the filter is of the search associated with Search.GetTable is the filter parameter of the prior Application.AdvancedSearch.
Search Completion Use the AdvancedSearchComplete event to determine when a given search has completed. Does not provide a callback to indicate search completion. Search is completed in the prior Application.AdvancedSearch. Search.GetTable only returns the search results.
Search Results Access the search results by one of these means:
  • Search.Results contains the search results as a Results collection. Each item in the collection contain the full set of item properties.
  • Search.Save saves the results to a search folder.
  • Search.GetTable also returns the same set of items as in the Results collection, but each item will contain only a default set of properties and therefore generally offers better performance.
Search results are displayed in the Explorer for the current folder. To remove any search results in the Explorer, call Explorer.ClearSearch. Search results are returned in a Table which includes the same set of items returned from the prior Application.AdvancedSearch. Since the Table only includes a limited set of properties per item, this is generally a more efficient way to access search results. To include properties other than the default in the search results, use Columns.Add to get an updated Table. Since the item's Entry ID is one of the returned properties, you can also use GetItemFromID to obtain the item object, and access other item properties like Body and AutoResolvedWinner that are not supported by the Table object for performance reasons.

See Also