Implementing the PreprocessMessage Function for Preprocessors
The MAPI spooler calls the PreprocessMessage function for messages that meet the preprocessor's criteria for MAPIUID or address type. PreprocessMessage can do several things with the input message:
Modify the input message. To modify the input message, the PreprocessMessage function calls the IMAPIProp::OpenProperty method with the MAPI_MODIFY flag for one or more properties of the input message. It then modifies the values of those properties, and calls IMAPIProp::SaveChanges to make the changes permanent.
Generate new messages to be sent as well. To generate new messages, the PreprocessMessage function must use its MAPI session pointer to access a message store provider through which it can create new message objects. New messages should be created using the default message store. These new message objects should be passed back to the MAPI spooler in the lpppMessage pointer, which is a pointer to an array of message object pointers. The original input message, however, should never be placed in this array.
Prevent the input message from being sent. To prevent the input message from being sent, the PreprocessMessage function must remove all the recipients from the message's recipient list and set the PR_DELETE_AFTER_SUBMIT property on the message. This will prevent the MAPI spooler from submitting the message to any transport providers.
Modify the recipient list of a message.
If multiple message preprocessors are being used, the individual PreprocessMessage functions are called in the same order as the transports. This order can be modified programmatically if your preprocessor needs to be called at some specific point in the transport order. See IMAPISession::AdminServices, IMsgServiceAdmin::MsgServiceTransportOrder and IXPLogon::AddressTypes for details.