This documentation is archived and is not being maintained.


This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Locks or unlocks a message. This method is called only by the MAPI spooler.

HRESULT SetLockState(
  LPMESSAGE lpMessage,
  ULONG ulLockState  


[in] A pointer to the message to lock or unlock.


[in] A value that indicates whether the message should be locked or unlocked. One of the following values is valid:


The message should be locked.


The message should be unlocked.


The lock state of the message was successfully set.

The IMsgStore::SetLockState method locks or unlocks a message. SetLockState can be called only by the MAPI spooler while it is sending the message.

Usually, when the MAPI spooler calls SetLockState to lock a message, it locks only the oldest message (that is, the next message queued for the MAPI spooler to send). If the oldest message in the queue is waiting for a temporarily unavailable transport provider, and the next message in the queue uses a different transport provider, the MAPI spooler can begin processing the later message. It begins processing by locking that message by using SetLockState.

After the MAPI spooler has called SetLockState with the ulLockState parameter set to MSG_LOCKED, calls to the IMsgStore::AbortSubmit method to cancel the message's transmission must fail.

Call the message's IMAPIProp::SaveChanges method in your SetLockState implementation so that any changes that were made to the message before the SetLockState call was received are saved.