Platform SDK: Exchange Server

Creating and Posting a Message

Posting messages and documents to folders (as opposed to sending messages) is a common action performed by client applications. For example, a client application may post information to a public folder as a way of allowing the associated server application to read the information.

The message class for a posted message (IPM.POST) differs from the message class for a message to be sent (IPM.NOTE). It is important that this property be set in the message. See step 3 in the following procedure.

To post a message

  1. Open the folder in which you want the new message to exist. See Opening an Existing Public Folder and Opening an Existing Private or Personal Folder.
  2. Create a new message with a call to the IMAPIFolder::CreateMessage method. This creates the message object and returns a pointer (LPMESSAGE) to it, which gives access to the MAPI IMessage interface on the new object.
  3. Set the PR_MESSAGE_CLASS property to IPM.POST. Set this and other properties on the message by calling IMAPIProp::CopyProps or IMAPIProp::SetProps. Some properties are required and others are optional. For a list of message properties that are automatically set, see Properties Set at Message Creation.
  4. Optionally, you can use the MAPI IMessage::SetReadFlag method to set (or clear) the read flag of the message so that it displays as read or unread.
  5. Commit the properties you have set by calling IMAPIProp::SaveChanges. The message will appear in the folder in which it was created.