Message store providers are not required to support outgoing message submissions — that is, the ability for client applications to use the message store provider to send messages. Client applications need to use a message store while sending messages because the message's data must be stored somewhere between the time that the user is finished composing it and the time that the MAPI spooler gives the message to a transport provider for submission to the underlying messaging system. If your message store provider does not support outgoing message submissions, it cannot be used as the default message store.
The SetLockState method is important for proper interoperation between the MAPI spooler and clients. When the MAPI spooler calls SetLockState on an outgoing message, the message store provider must not let clients open the message. If a client does try to open a message that is locked by the MAPI spooler, the message store provider should return MAPI_E_NO_ACCESS. The locked state of a message does not have to be persistent in case the store is shut down while the message is locked by the MAPI spooler.
Regardless of whether the MAPI spooler has locked an outgoing message, the message store provider should not allow a message in the outgoing message queue to be opened for writing. If a client calls the IMSgStore::OpenEntry method on an outgoing message with the MAPI_MODIFY flag, the call should fail and return MAPI_E_SUBMITTED. If a client application calls OpenEntry on an outgoing message with the MAPI_BEST_ACCESS flag, the message store provider should allow read-only access to the message.
When a message is to be handled by the MAPI spooler, the message store provider sets the message's PR_SUBMIT_FLAGS property to SUBMITFLAG_LOCKED. The SUBMITFLAG_LOCKED value indicates that the MAPI spooler has locked the message for its exclusive use. The other value for PR_SUBMIT_FLAGS, SUBMITFLAG_PREPROCESS, is set when the message requires preprocessing by one or more preprocessor functions registered by a transport provider.
The following three procedures describe how the message store, transport, and MAPI spooler interact to send a message from a client to one or more recipients.
The client application calls the IMessage::SubmitMessage method.
1. Locks the message by calling IMsgStore::SetLockState. |
2. Performs the needed preprocessing by calling all of the preprocessing functions in the order of registration. Transport providers call IMAPISupport::RegisterPreprocessor to register preprocessing functions. |
3. Calls IMessage::SubmitMessage on the open message to indicate to the message store that preprocessing is complete. |
Note The following two steps will occur in the client process if there was no preprocessing, and will occur when the MAPI spooler calls SubmitMessage if there was preprocessing.
1. Calls IMAPISupport::CompleteMsg if the message was preprocessed or the message store provider wants the MAPI spooler to complete message processing which is recommended so that messaging hooks can be invoked. Message flow continues with the MAPI spooler as described in the following procedure. |
2. Performs the following tasks if the message was not preprocessed or the message store provider does not want the MAPI spooler to complete message processing: |
· Copies the message to the folder identified by the entry identifier in the PR_SENTMAIL_ENTRYID property, if set. |
· Deletes the message if the PR_DELETE_AFTER_SUBMIT property has been set to TRUE. |
· Unlocks the message if it is locked. |
· Returns to the client. Message flow is complete. |
1. Calls IMAPISupport::CompleteMsg. |
2. Message flow continues with the MAPI spooler. See Sending Messages: MAPI Spooler Tasks. |
1. Copies the message to the folder identified by the entry identifier in the PR_SENTMAIL_ENTRYID property, if set. |
2. Deletes the message if the PR_DELETE_AFTER_SUBMIT property has been set to TRUE. |
3. If the message is locked, unlocks it. |
4. Returns to the caller. Message flow is complete. |