Developing a Hook Provider or Preprocessor
MAPI defines two types of extensions that it uses to allow custom code to be inserted into the message transmission and reception processes—hook providers and preprocessors. A hook provider, also called a spooler hook, can be called after an outbound message reaches the transport providers and before an inbound message is delivered to the default folder for its message class. Preprocessors operate on outbound messages only and are called before and after transport providers handle the message.
Since hook providers and preprocessors act during the message sending and receiving processes, you should familiarize yourself with the roles that other MAPI components play in these processes. Specifically, you should read Sending Messages with MAPI, Service Provider Basics, Developing a Transport Provider, and Developing a Message Store Provider. You do not need to learn the material in these sections in any great detail in order to implement a hook provider or preprocessor, but you should have a basic understanding of the way these components interact to send and receive messages.
There are several things to consider when choosing whether to use a hook provider or a preprocessor to implement your custom code:
-
Whether your component needs to be able to operate on inbound messages. If it needs to act on inbound messages, you must use a hook provider, since preprocessors are not called for inbound messages.
-
Whether your component needs to operate before or after transport providers for outbound messages. Preprocessors are called before transport providers, hook providers are called after.
-
What your component needs to do. Preprocessors are typically used to modify a message's contents or recipient list before sending. For example, a preprocessor can be used to automatically add a signature to outgoing messages. Hook providers are typically used to archive messages or automatically file them in different folders; that is, to manipulate the relationship between the message and its message store although they can also modify a message's content. Hook providers cannot, however, modify a message's recipients. Only preprocessors can cause a message to be sent to different recipients than those entered by the user sending the message.
-
Ease of implementation. Hook providers are actual MAPI service providers, albeit simple ones, and must follow the guidelines for service providers. However, preprocessors have to be registered by means of a transport provider. If you also happen to have a transport provider that you can modify to register the preprocessor, then creating a preprocessor is probably easier than creating a hook provider. If not, you will have to create a minimal transport provider whose sole job is to register the preprocessor.
For an overview of the process of creating hook providers and preprocessors, see Using Message Filtering to Manage Messages.