IMAPISession::Advise

4/8/2010

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

Syntax

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

Parameters

  • cbEntryID
    [in] Must be 0.
  • lpEntryID
    [in] Must be NULL.
  • 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. See Remarks for valid flags that can be combined for this parameter.
  • lpAdviseSink
    [in] Reference to an advise sink object, implemented on IMAPIAdviseSink, to receive the subsequent notifications. This advise sink object must have already been allocated; it cannot be NULL.
  • lpulConnection
    [out] Reference to a nonzero number that represents the connection between the caller's advise sink object and the session.

Return Value

This method returns the standard values E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, and E_FAIL, as well as the following:

  • S_OK
    Indicates success.

Remarks

Advise establishes a connection between the caller's advise sink object and the session. 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 session.

The ulEventMask parameter is a bitmask composed of one or more of the flags described in the following table.

Flag Value Description

fnevObjectCopied

0x00000040

Registers for notifications about an object being copied.

fnevObjectCreated

0x00000004

Registers for notifications about the creation of a new object.

fnevObjectDeleted

0x00000008

Registers for notifications about an object being deleted.

fnevObjectModified

0x00000010

Registers for notifications about an object being modified.

fnevObjectMoved

0x00000020

Registers for notifications about an object being moved.

To send a notification, 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.

After a call to Advise has succeeded and beforeIMAPISession::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.

Requirements

Header mapix.h
Library cemapi.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Pocket PC 2002 and later, Smartphone 2002 and later

See Also

Reference

IMAPISession
IMAPIAdviseSink::OnNotify
IMAPISession::Unadvise

Other Resources

Messaging