Implementing Advanced Searching

Applies to: Outlook 2013 | Outlook 2016

Some address book containers support an advanced searching capability that allows clients to search on properties other than PR_DISPLAY_NAME (PidTagDisplayName). To support advanced searches, your provider must implement a special container that is accessible through the PR_SEARCH (PidTagSearch) property of your other containers. PR_SEARCH contains a container object that provides access to a display table that describes the dialog box used to enter and edit the advanced search criteria.

To support advanced searching

  1. Define a property for each of your search criteria.

  2. In the section of code in your container's IMAPIProp::OpenProperty method that handles the PR_SEARCH property:

  3. Check that the client is requesting the IMAPIContainer interface. If an inappropriate interface is being requested, fail and return MAPI_E_INTERFACE_NOT_SUPPORTED.

  4. Create a new search object that supports the IMAPIContainer interface.

  5. At this point, a call will be made to your search container's IMAPIProp::OpenProperty method to retrieve its PR_DETAILS_TABLE (PidTagDetailsTable) property. Your provider must supply a display table, typically through a call to BuildDisplayTable, that describes the container's advanced search dialog box.

  6. MAPI displays the search dialog box, allowing the user to enter the appropriate criteria. When the user has finished, MAPI calls the container's IMAPIProp::SetProps method to store the search criteria.

  7. A call will be made to request your search container's contents table. Populate the contents table with all of the entries in the container that match the criteria.