Platform SDK: Exchange Server |
When a new message arrives in a user’s Inbox, a session event is sent to Microsoft Exchange. Extensions can be notified when a new message arrives by installing themselves in the EECONTEXT_SESSION context and by implementing the IExchExtSessionEvents : IUnknown interface, which supports only one method: IExchExtSessionEvents::OnDelivery. Whenever a session event occurs, Microsoft Exchange calls this method on all extensions that are registered to handle these events.
OnDelivery passes a pointer to the IExchExtCallBack : IUnknown interface to the extension, which uses the pointer to obtain details about the current context. The extension returns S_OK from OnDelivery if it will handle the event. For example, an extension might use the IExchExtCallBack pointer to determine the class of the newly arrived message. If the message class is of a specific type, the extension might want to perform a custom operation on that message, such as extracting its properties and storing them in a database.
Note IExchExtSessionEvents::OnDelivery is called after the Microsoft Exchange Server has processed the rules attached to the folder. Therefore, OnDelivery will not be called if it was previously handled; for example, if a rule deleted the message. Because this is a server process, rules processing is performed prior to all extensions.