Last modified: July 23, 2011

Applies to: Outlook

Registers the caller to receive notification of specified events that affect a container, messaging user, or distribution list.

  ULONG cbEntryID,
  ULONG ulEventMask,
  ULONG FAR * lpulConnection


[in] The count of bytes in the entry identifier pointed to by the lpEntryID parameter.


[in] A pointer to the entry identifier of the object about which notifications should be generated.


[in] A bitmask of values that indicate the types of notification events that the caller is interested in and should be included in the registration. There is a corresponding NOTIFICATION structure associated with each type of event that holds information about the event. The following table lists the valid values for the ulEventMask parameter and the structures associated with each value.

Notification event type

Corresponding NOTIFICATION structure














[in] A pointer to an advise sink object to receive the subsequent notifications.


[out] A pointer to a nonzero value that represents the notification registration.


The notification registration was successful.


The entry identifier passed in the lpEntryID parameter is not in the appropriate format.


The address book provider does not support notification, possibly because it does not allow changes to be made to its objects.


The address book provider cannot handle the entry identifier passed in lpEntryID.

Address book providers implement the IABLogon::Advise method to register the caller to be notified when a change occurs to an object in one of their containers. Callers can register for notifications regarding messaging users, distribution lists, or entire containers.

Clients typically call the IAddrBook::Advise method to register for address book notifications. MAPI then calls the Advise method of the address book provider that is responsible for the object represented by the entry identifier in lpEntryID.

When a change occurs to the indicated object of the type represented in ulEventMask, a call is made to the OnNotify method of the advise sink pointed to by lpAdviseSink. Data passed in the NOTIFICATION structure to the OnNotify routine describes the event.

You can support notification with or without help from MAPI. MAPI has three support object methods to help service providers implement notification:

If you elect to use the MAPI support methods, call Subscribe when your Advise method is called and release the lpAdviseSink pointer.

If you elect to support notification yourself, call the AddRef method of the advise sink represented by the lpAdviseSink parameter to keep a copy of this pointer. Maintain this copy until your IABLogon::Unadvise method is called to cancel the registration.

Regardless of how you support notification, assign a nonzero connection number to the notification registration and return it in the lpulConnection parameter. Do not release this connection number until the Unadvise method has been called.

The advise sink pointer that you pass in the lpAdviseSink parameter to Advise can point to an object that you have created or that MAPI has created through the HrThisThreadAdviseSink function. You might want to use HrThisThreadAdviseSink if you support multiple threads of execution and want to be sure that that subsequent calls to your OnNotify method occur at an appropriate time on an appropriate thread.

Be prepared for your advise sink object to be released any time after your call to Advise and before your call to Unadvise. Therefore, you should release your advise sink object after Advise returns, unless you have a specific long-term use for it.

For more information about the notification process, see Event Notification in MAPI. For information about how to use the IMAPISupport methods to support notification, see Supporting Event Notification. For more information about multithreading and MAPI, see Threading in MAPI.

© 2015 Microsoft