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.
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.