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.
Comments
Anonymous
January 09, 2009
I came across your post while searching for some other problem. I feel you may answer my query. I am trying to convert MSG file having 80 MB attachment into EML file. But the method IConverterSession::MAPIToMIMEStm takes lot of time (almost 10 minutes on my system) for conversion. Is there any way to convert the MSG into EML in faster way?Anonymous
January 09, 2009
It might go a lot faster if you've converted the MSG to a MAPI message in a store first. But that conversion itself may take a while - that's a rather large message for the .MSG format.Anonymous
January 12, 2009
Hi, Do you know if there is some other property that is "required" to be set along with an unset MSGFLAG_UNSENT. My attempts to unset this flag seem to be failing. -Thanks.Anonymous
January 12, 2009
i have set the MSGFLAG_READ using SETREADFLAGS method.Now i want to check that flag for each message whether it is set or not.Please say some clue or any tries. I have spent 2 days searching this. Thanx & regards vickyAnonymous
January 13, 2009
Vicky - get the PR_MESSAGE_FLAGS property from the message and check if the flag is set in there.