Timing a Notification

Because event notification is an asynchronous process, you can be notified at any time, not necessarily immediately after the event has occurred. The timing of calls to your IMAPIAdviseSink::OnNotify method varies depending on the service provider implementing the advise source. Service providers can notify your client either:

Most service providers call OnNotify after the MAPI method responsible for the event has returned to its caller. For example, notifications on messages are sent either when changes to the message are saved, after the IMAPIProp::SaveChanges call, or when the message is released, after the IUnknown::Release call. Until the notification is sent, no changes are visible in the message store.

You can receive notifications from an advise source after you have called Unadvise to cancel a registration. Be sure to release your advise sink only after its reference count has fallen to zero, not following a successful Unadvise call. Do not assume that because you have called Unadvise that the advise sink is no longer necessary.