Registers to receive notification of specified events that affect the session.
[in] The byte count in the entry identifier pointed to by the lpEntryID parameter.
[in] A pointer to the entry identifier of the address book or message store object about which notifications should be generated, or NULL, which indicates that the client is registering to receive notifications about events that affect only the session.
[in] A mask of values that indicate the types of notification events that the client is interested in and should be included in the registration. If lpEntryID is NULL, MAPI automatically registers the client for critical error events that affect only the session. When lpEntryID points to an entry identifier, the following values are valid for the ulEventMask parameter:
Registers for notifications about severe errors, such as insufficient memory.
Registers for notifications about events specific to a particular address book or message store provider and about session shut down.
Registers for notifications about the arrival of new messages.
Registers for notifications about the creation of a new object.
Registers for notifications about an object being copied.
Registers for notifications about an object being deleted.
Registers for notifications about an object being modified.
Registers for notifications about an object being moved.
Registers for notifications about the completion of a search operation.
[in] A pointer to an advise sink object to receive the subsequent notifications. This advise sink object must have already been allocated.
[out] A pointer to a nonzero number that represents the connection between the caller's advise sink object and the session.
The registration was successful.
The entry identifier pointed to by lpEntryID does not represent a valid entry identifier.
The service provider responsible for the entry identifier pointed to by lpEntryID either does not support the type of events specified in the ulEventMask parameter or does not support notification.
The entry identifier pointed to by lpEntryID cannot be handled by any of the service providers in the profile.
The IMAPISession::Advise method establishes a connection between the caller's advise sink object, the session and, optionally, a service provider. This connection is used to send notifications to the advise sink when one or more events specified in the ulEventMask parameter occur to the object pointed to by lpEntryID. When lpEntryID is NULL, the target object is the session and notifications are sent only for critical errors and extended events.
When lpEntryID points to a valid entry identifier, MAPI calls the Advise method of the logon object that belongs to the responsible service provider. For example, if lpEntryID points to the entry identifier of a distribution list, MAPI calls the appropriate address book provider's IABLogon::Advise method.
To send a notification, either the service provider or MAPI calls the registered advise sink's IMAPIAdviseSink::OnNotify method. One of the parameters to OnNotify, a notification structure, contains information that describes the specific event.
On systems that support multiple threads of execution, the call to OnNotify can also occur on any thread at any time. If you need assurance that notifications will occur only at a particular time on a particular thread, call the HrThisThreadAdviseSink function to generate the advise sink object that you pass to the Advise method.
To determine when a client has logged off, register for notifications in your service provider by calling Advise with lpEntryID set to NULL and cbEntryID set to 0. When the logoff occurs, you will receive an fnevExtended notification.
After a call to Advise has succeeded and before IMAPISession::Unadvise has been called to cancel the registration, release your advise sink object unless you have a specific long-term use for it.
For an overview of the notification process, see Event Notification in MAPI.
For more information about handling notifications, see Handling Notifications.