Reputation: 9425
I would like to know if there is any way to compare two Outlook.MailItem
s to see if they are the same.
For example, If two people in our company receive the same email, is there a way to compare them for equality?
I was thinking about comparing the the folowing properties:
Subject
, To
, From
, CC
, Body
which may work 99% of the time, however as the database grows bigger and bigger this routine will become slower and slower.
Is there a better way to acheive this?
Upvotes: 4
Views: 2042
Reputation: 14700
Rather than creating your own hash function, you should use the one really used by the system. In the case of Exchange items, you can check the item's EntryID to get the Exchange ID for the item. I think it will be unique for a local PST as well, but you should make sure of that.
Upvotes: 1
Reputation: 733
If you are storing the values, then a hashcode of the properties might be the way to go, using the properties you stated. You could then make this an indexed column to improve search and retrieval performance.
So I guess in C# :
var mailHash = String.Format("{0}{1}{2}{3}{4}", mail.To, mail.From, mail.CC, mail.Subject, mail.Body).GetHashCode();
Would that work for you?
Cheers,
Chris.
Upvotes: 3