The CreateMessage method creates a new message within the current folder.


HRESULT CreateMessage (
  LPCIID lpInterface,
  ULONG ulFlags,
  LPMESSAGE FAR * lppMessage


  • lpInterface
    [in] Must be NULL.
  • ulFlags
    [in] Must be zero.
  • lppMessage
    [out] Reference to the newly created message, implemented on IMessage.

Return Value

This method returns the standard values E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, and E_FAIL, as well as the following:

  • S_OK
    Indicates success.


CreateMessage creates a new message with generic or associated content and assigns an entry identifier. The entry identifier is made up of a part that represents the message store provider and a part that represents the individual message.

The lppMessage must be released to clean up the allocated memory.

The entry identifier of the new message is available immediately after CreateMessage returns.

Expect the entry identifier assigned to the new message to be unique within the current message store as well as across all of the message stores that are open concurrently. One exception to this general rule occurs when multiple entries for a message store appear in the profile, causing the message store to be opened multiple times and entry identifiers to be duplicated.

To create an outgoing message, call the Outbox folder's CreateMessage method. Then call IMessage::SubmitMessage to actually send the message.

If you delete a folder containing a new message before the message is saved, the results are undefined.


Header mapidefs.h
Library cemapi.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Pocket PC 2002 and later, Smartphone 2002 and later

See Also



Other Resources