IABLogon::Advise

The IABLogon::Advise method registers to receive notification of specified events affecting a container, messaging user, or distribution list.

Quick Info

See IABLogon : IUnknown.

HRESULT Advise(
  ULONG cbEntryID,                 
  LPENTRYID lpEntryID,             
  ULONG ulEventMask,               
  LPMAPIADVISESINK lpAdviseSink,   
  ULONG FAR * lpulConnection       
);
 

Parameters

cbEntryID
[in] Count of bytes in the entry identifier pointed to by the lpEntryID parameter.
lpEntryID
[in] Pointer to the entry identifier of the object about which notifications should be generated.
ulEventMask
[in] A mask of values indicating 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
fnevCriticalError
ERROR_NOTIFICATION
fnevObjectCreated
OBJECT_NOTIFICATION
fnevObjectDeleted
OBJECT_NOTIFICATION
fnevObjectModified
OBJECT_NOTIFICATION
fnevObjectCopied
OBJECT_NOTIFICATION
fnevObjectMoved
OBJECT_NOTIFICATION

lpAdviseSink
[in] Pointer to an advise sink object to receive the subsequent notifications.
lpulConnection
[out] Pointer to a nonzero value that represents the notification registration.

Return Values

S_OK
The notification registration was successful.
MAPI_E_INVALID_ENTRYID
The entry identifier passed in lpEntryID is not in the appropriate format.
MAPI_E_NO_SUPPORT
The address book provider does not support notification, possibly because it does not allow changes to be made to its objects.
MAPI_E_UNKNOWN_ENTRYID
The address book provider cannot handle the entry identifier passed in lpEntryID.

Remarks

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 on messaging users, distribution lists, or entire containers.

Clients typically call IAddrBook::Advise to register for address book notifications. MAPI then calls the IABLogon::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.

Notes to Implementers

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

IMAPISupport::Subscribe

IMAPISupport::Unsubscribe

IMAPISupport::Notify

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 IUnknown::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 Unadvise has been called.

Notes to Callers

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 ensure 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. MAPI recommends that you release your advise sink object after Advise returns, unless you have a specific long-term use for it.

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

See Also

HrThisThreadAdviseSink, IABLogon::Unadvise, IMAPIAdviseSink::OnNotify, NOTIFICATION