IMAPISession::Advise

The IMAPISession::Advise method registers to receive notification of specified events affecting the session.

Quick Info

See IMAPISession : IUnknown2MVW67N.

 

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 address book or message store object about which notifications should be generated or NULL, indicating that the client is registering to receive notifications about events that affect only the session.

ulEventMask

[in] A mask of values indicating 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 for the session   the only type of event supported by the session.

When lpEntryID points to an entry identifier, the following values are valid for the ulEventMask parameter:

fnevCriticalError

Registers for notifications about severe errors, such as insufficient memory.

fnevExtended

Registers for notifications about events specific to the particular address book or message store provider.

fnevNewMail

Registers for notifications about the arrival of new messages.

fnevObjectCreated

Registers for notifications about the creation of a new object.

fnevObjectCopied

Registers for notifications about an object being copied.

fnevObjectDeleted

Registers for notifications about an object being deleted.

fnevObjectModified

Registers for notifications about an object being modified.

fnevObjectMoved

Registers for notifications about an object being moved.

fnevSearchComplete

Registers for notifications about the completion of a search operation.

lpAdviseSink

[in] Pointer to an advise sink object to receive the subsequent notifications. This advise sink object must have already been allocated.

lpulConnection

[out] Pointer to a nonzero number that represents the connection between the caller s advise sink object and the session.

 

Return Values

S_OK

The registration was successful.

MAPI_E_INVALID_ENTRYID

The entry identifier pointed to by lpEntryID does not represent a valid entry identifier.

MAPI_E_NO_SUPPORT

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.

MAPI_E_UNKNOWN_ENTRYID

The entry identifier pointed to by lpEntryID cannot be handled by any of the service providers in the profile.

 

Remarks

The IMAPISession::Advise method establishes a connection between the caller s advise sink object, the session, and, as an option, a service provider. This connection is used to send notifications to the advise sink when one or more events as 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 for critical error events only.

When lpEntryID points to a valid entry identifier, MAPI calls the Advise method of the logon object belonging 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::OnNotify5WYI5X method. One of the parameters to OnNotify, a notification structure, contains information that describes the specific event.

Notes to Callers

On systems that support multiple threads of execution, the call to OnNotify can also occur on any thread at any time. If you must be assured that notifications only occur at a particular time on a particular thread, call HrThisThreadAdviseSinkGC_JPU to generate the advise sink object that you pass to Advise.

After a call to Advise has succeeded and before Unadvise has been called to cancel the registration, be prepared for the advise sink object to be released. You should release your advise sink object after Advise returns unless you have a specific long-term use for it.

For an overview of the notification process, see Event Notification in MAPIE.8REW.

For more information on handling notifications, see Handling Notifications1Q6HBVG.

See Also

NOTIFICATION, HrThisThreadAdviseSink, IMAPIAdviseSink::OnNotify, IMAPISession::Unadvise