1

I have an access database which stores the details of a email including send date, contacts, message body, entryid, conversationid, etc but I based on my research the entryid changes if the email is moved. Well our emails get moved around a lot since its a shared mailbox. Therefore I was trying to find a solution to search outlook for a unique id that doesnt change. Everything I have found on this forum and others points to the message ID. The issue I am coming across is to get the message id you need to use the following code:

.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001F")

which returns a lot of information and not just the message-ID. The other issue I am coming across is I am unsure of the best method to search through the outlook mailboxes for this message-id. Is my only option to loop through all emails and get their properties and extract the message-id and compare to the one I am search for?

Irish Redneck
  • 983
  • 7
  • 32

1 Answers1

2

First of all, there is no need to retrieve the whole message header. You can just get the PR_INTERNET_MESSAGE_ID property value, the DASL name is "http://schemas.microsoft.com/mapi/proptag/0x1035001E".

That internet message ID property is only sent after the message is sent. Exchange sets that property for all messages created in the store, but you will not necessarily see it on messages in the cached store.

' "PR_INTERNET_MESSAGE_ID"
propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x1035001E")

Note, you can assign your own ID to items in Outlook. For example, you can add a user property to items with your own ID. See UserProperties.Add for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Oh thanks for that! What would be the best/most efficient vba method to search for a specific message by this property. Would be it be to do advancesearch() and set the filter to this dasl name or is there a cleaner way to search on this dasl name to return the mailitem? – Irish Redneck Aug 13 '19 at 15:52
  • is there any reference link where i can get all the DSL names ? – th1rdey3 Aug 03 '22 at 07:58
  • The DASL property name string is constructed from the MAPI property tag. – Eugene Astafiev Aug 03 '22 at 08:02