Did I Send That?

[This is now documented here: https://msdn.microsoft.com/en-us/library/ff960604.aspx ]

We had a customer here who wondered why messages imported into MAPI using MIMEToMAPI always appeared as draft messages. This is because the default value of PR_MESSAGE_FLAGS includes the MSGFLAG_UNSENT flag. Now - if you know you want your messages to not appear as drafts, the thing to do here is to clear the MSGFLAG_UNSENT flag before saving the message.

But what if you're exporting messages from mailbox using MAPIToMIMEStm and importing them using MIMEToMAPI, and want to preserve the sent/unsent state across this conversion? One thing you could do is read the state during the export, save it off somewhere (perhaps as a header in the EML file), then use it to determine if the flag needs to be cleared.

Doable - but a bit of extra work. Turns out there's  flag you can use in those functions that has nearly the same effect: CCSF_EMBEDDED_MESSAGE

Here's the documentation on the flag:

Flag value:

 #define CCSF_EMBEDDED_MESSAGE 0x8000 // sent/unsent information is persisted in X-Unsent

IConverterSession::MAPIToMIMEStm

When CCSF_EMBEDDED_MESSAGE is set, if PR_MESSAGE_FLAGS has the MSGFLAG_UNSENT flag set, add an X-Unsent header to the MIME message with a value of 1

IConverterSession::MIMEToMAPI

When CCSF_EMBEDDED_MESSAGE is set, the resultant MAPI message will have MSGFLAG_READ set in PR_MESSAGE_FLAGS. In addition, if an X-Unsent header is found with a value of 1, the MSGFLAG_UNSENT flag is removed from PR_MESSAGE_FLAGS.

Remarks

This flag may be used in Outlook 2003 and higher. The name of this flag reflects the way it originally was used, as a way to deal with embedded messages. It is no longer used in this fashion. If the side effect of setting MSGFLAG_READ is not desired, this flag should not be used. If this flag is not set, MIMEToMAPI will ignore any value in X-Unsent and MSGFLAG_UNSENT will be set in PR_MESSAGE_FLAGS. MAPIToMIMEStm will not write the X-Unsent header at all if the MSGFLAG_UNSENT flag is not set in PR_MESSAGE_FLAGS.