The MAPI spooler makes calls to two different types of extensions by which code can be inserted in the message transmission process. These extensions — known as preprocessors and spooler hooks — can be used for a wide variety of purposes including altering the recipient list or content of an outbound message, archiving outbound messages in local storage or on a central server, directing inbound messages to a particular folder based on arbitrary criteria, and responding automatically to inbound messages.
A preprocessor is called for outbound messages only. It may choose to be called for all messages, or for messages that have recipients of a particular type. Those recipients can be selected based on the address type (PR_ADDRTYPE), on the MAPIUID which qualifies the recipient's entry identifier, or both. See IMAPISupport::RegisterPreprocessor.
A preprocessor can create new messages based on the input message, returning them through its lpppMessage parameter. In no case should the input message be placed in the lpppMessage parameter. If a preprocessor does not want the input message to be sent, it should delete all the recipients and set the PR_DELETE_AFTER_SUBMIT property; the input message should not be deleted using message store calls.
A spooler hook may choose to be called for all inbound messages, all outbound messages, or both, by setting the HOOK_INBOUND flag, the HOOK_OUTBOUND flag, or both in its PR_RESOURCE_FLAGS property on the provider profile section in MAPISVC.INF. See File Format of MAPISVC.INF.
To delete an inbound or outbound message, a hook should set the HOOK_DELETE flag in its lpulFlags parameter. It should not use message store calls to delete the message presented to it through its interface; it may use message store calls to create, modify, or delete other messages. A hook can prevent processing of a message by other hooks, including the default hook that processes receive folder settings, by setting the HOOK_CANCEL flag in lpulFlags.
When working with a tightly coupled message store and transport, the store itself can transmit a message that is not destined for any spooler-based transports. Whether preprocessors and hooks are called in this situation depends upon the message store implementation. Microsoft Exchange Server, for example, calls preprocessors on outbound messages but does not call either inbound or outbound spooler hooks. See Sending Messages with MAPI.
On an outbound message, hooks and preprocessors participate in a complicated sequence of events. The following steps involve hooks and preprocessors.
For inbound messages, preprocessors are not called. Hooks are called as follows:
See the following topics:
Sample Messaging Hook Provider