Outlook.MailItem. Is there a way to determine if two mailings (sent for different recipients) are the same?

I would like to know if there is a way to compare the two Outlook.MailItem to make sure 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 following properties:

Subject , To , From , CC , Body

which can work in 99% of cases, but as the database grows and grows, this procedure will be slower and slower.

Is there a better way to achieve this?

+4
source share
2 answers

If you store the values, then the hash of the properties can be a way using the specified properties. You can then do this with an indexed column to improve search and search performance.

So, I think in C #:

 var mailHash = String.Format("{0}{1}{2}{3}{4}", mail.To, mail.From, mail.CC, mail.Subject, mail.Body).GetHashCode(); 

Will this work for you?

Cheers
Chris.

+3
source

Instead of creating your own hash function, you should use the one that is actually used by the system. For Exchange elements, you can check the EntryID element to get the Exchange identifier for that element. I think it will be unique for the local PST as well, but you have to make sure of this.

+1
source

Source: https://habr.com/ru/post/1394369/


All Articles