outlookvstomapi

Are some MAPI named properties known and thus always return the same Tag when using GetIDsFromNames with MAPI_CREATE?


In my c# VSTO Outlook project I am using the GetNamesFromIDs to get a property name from one message and then adding it to a second message with GetIDsFromNames with the MAPI_CREATE flag set so that the property is added. I then add the value.

My understanding of GetIDsFromNames is that when it sets a "new" property then a new and unique tag is generated. This is done so that tags do not clash.

  1. Is it possible on a newly created message that setting a named property with GetIDsFromNames that MAPI gives it the same Tag number it has had on previous messages?
  2. Am I right that GetNamesFromIDs accepts, and GetIDsFromNames returns, only the the upper 2 byte property id and to use what I get from GetIDsFromNames I need to add back the type?

No.2 I cannot seem to read anywhere.


Solution

    1. Yes, that is exactly how it works - once a mapping it created, is stays the same for the lifetime of the parent message store. You can see existing mapping in OutlookSpy (I am its author) - click IMsgStore button (or IMAPIFolder or IMessage) and then GetNamesFromIDs button.

    2. Yes, you always need to set the type. Keep in mind that once a property is used (i.e. used to set a property) with a particular type (unless it is PT_STRING8 vs PT_UNICODE), you will not be able to use that property with a different type.