Last modified: July 23, 2011

Applies to: Outlook

Provides access to the address book.

HRESULT OpenAddressBook(
LPCIID lpInterface,
ULONG ulFlags,


[in] A pointer to the interface identifier (IID) that represents the interface to be used to access the address book. Valid values are NULL, which indicates the standard address book interface IAddrBook, and IID_IAddrBook.


Reserved; must be zero.


[out] A pointer to a pointer to the address book.


Access to the address book was provided.


The call succeeded, but one or more address book providers could not be loaded. When this warning is returned, the call should be handled as successful. To test for this warning, use the HR_FAILED macro. For more information, see Using Macros for Error Handling.

The IMAPISupport::OpenAddressBook method is implemented for all service provider support objects. Service providers, typically tightly coupled message store and transport providers, call OpenAddressBook to get access to the address book. The returned IAddrBook pointer can be used for a variety of address book tasks, including opening address book containers, finding messaging users, and displaying address dialog boxes.

OpenAddressBook can return MAPI_W_ERRORS_RETURNED if it cannot load one or more of the address book providers in the current profile. This value is a warning and you should treat the call as successful. Even if all of the address book providers failed to load, OpenAddressBook still succeeds, returning MAPI_W_ERRORS_RETURNED and an IAddrBook pointer in the lppAdrBook parameter. Because OpenAddressBook always returns a valid IAddrBook pointer, you must release it when you are finished using it.

If one or more address book providers failed to load, call IMAPISupport::GetLastError to obtain a MAPIERROR structure that contains information about the providers that did not load.