Platform SDK: MAPI

IMAPISupport::OpenAddressBook

The IMAPISupport::OpenAddressBook method provides access to the address book.

Quick Info

See IMAPISupport : IUnknown.

HRESULT OpenAddressBook(
  LPCIID lpInterface,         
  ULONG ulFlags,              
  LPADRBOOK FAR * lppAdrBook  
);
 

Parameters

lpInterface
[in] Pointer to the interface identifier (IID) representing the interface to be used to access the address book. Valid values are NULL, indicating the standard address book interface — IAddrBook — and IID_IAddrBook.
ulFlags
Reserved; must be zero.
lppAdrBook
[out] Pointer to a pointer to the address book.

Return Values

S_OK
Access to the address book was provided.
MAPI_W_ERRORS_RETURNED
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. See Using Macros for Error Handling.

Remarks

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.

Notes to Callers

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 containing information about the providers that did not load.

See Also

IAddrBook : IMAPIProp, IMAPISession::OpenAddressBook