Posting a message
Applies to: Outlook 2013 | Outlook 2016
Posting a message is similar to sending a message. The main difference is the destination. Rather than being directed to one or more recipients across one or more messaging systems, a posted message remains in a folder in the current message store.
To post a message
Open the destination folder by calling IMsgStore::OpenEntry. If the destination folder is the Inbox, locate the entry identifier to pass to OpenEntry by calling IMsgStore::GetReceiveFolder.
Call IMAPIFolder::CreateMessage to create the message.
Call the message's IMAPIProp::SetProps method to set:
The MSGFLAG_READ flag in the PidTagMessageFlags ( PR_MESSAGE_FLAGS) property.
The PR_SENDER properties.
The PR_SENT_REPRESENTING properties.
The PR_RECEIPT_TIME (PidTagReceiptTime) property.
The PR_RTF_COMPRESSED (PidTagRtfCompressed) or PR_BODY (PidTagBody) property.
The PR_SUBJECT (PidTagSubject) property.
The PR_MESSAGE_CLASS (PidTagMessageClass) property.
Any properties required by the message class.
Call the message's IMAPIProp::SaveChanges method to save the message.
If necessary, create an attachment, set its properties, and save it. For more information about adding attachments to messages, see Creating a Message Attachment.
Call IMessage::SaveChanges to save the message. At this point it will appear in the contents table of the destination folder.
Notice that you do not create a recipient list. Instead, you set several properties that are normally set by a transport provider for a sent message.
If you want to save a message intermittently before having it appear in the contents table of the visible folder, create it instead in a hidden folder such as the root folder of the IPM subtree and then move it to the target folder.