Search code examples
c++comoutlookatlwtl

Search Outlook Contact using COM?


I want to add support for searching for local Outlook contacts to my ATL/WTL app. Does anyone know of the Outlook COM interface (Office 2003 or greater) allows you to search for contacts? I already have LDAP lookup support but users want to be able to search their private contacts as well.

Any information would be welcome.


Solution

  • To get access to the contacts you first have to get a Namespace object using the Application's GetNamespace function, passing "MAPI" as the namespace name.

    Then you use Namespace's GetDefaultFolder function, which gives you a MAPIFolder interface which contains an Items property.

    Next you call the Find function on the items.