18

I'm trying to find the guaranteed unique identifier to distinguish emails from each other. Currently, I am writing an application which connects to Microsoft Exchange, however I want to be able to support other email services.

I think that the unique identifier is the EmailMessage.InternetMessageId, and that this property uses the PR_ENTRYID, except that I can't find any documentation to support this.

Do all emails have a unique identifier and is that (in Exchange) the InternetMessageId?

myermian
  • 31,823
  • 24
  • 123
  • 215

3 Answers3

15

There is no guaranteed unique id for emails, the Message-ID is about as close as you come. The best you can actually hope for is unique for the server...and even that depends upon the type of mail server and what it does.

jmoreno
  • 12,752
  • 4
  • 60
  • 91
  • 2
    Just to add that in Exchange, EntryID is related to the parent folder. Moving a message to a different folder will change its EntryID – Basic May 07 '15 at 16:35
4

I guess that's something never 100% guaranteed. I mean that number comes from special Email headers developed during time and described officially by specific RFC documents. Sometimes it may be a special information provided by a special service like Exchange (what you cited in your question). Even if I can't give you a really complete answer, I can tell for sure you should be aware of the fact you have no guarantees of unicity. For further reading I found an interesting answer on SO related to the above said header in the abstract domain of Internet Mail Messages: Is the "Message ID" Email Header unique for each recipient?

Community
  • 1
  • 1
Diego D
  • 6,156
  • 2
  • 17
  • 30
4

How about using a hash function that could yield a unique hash considering some elements of the email message. i.e. GetEmailHash(dateTimeReceived+sender+subject+body)

Rohit Poudel
  • 1,793
  • 2
  • 20
  • 24
syed
  • 41
  • 2