Grigoris Loukidis
Grigoris Loukidis

Reputation: 403

Microsoft add-in adds duplicates mails on shared folder

I have developed an Outlook add-in which filters mails and if they fit some standards it moves them to a shared folder, under a mailing list.

It works ok for one person, but when I added it to another one person of the mailing list, it moves again the incoming mail to the shared folder. So, I face duplicate mails.

Is it any way or strategy to prevent adding the same mail after first time or to replace the same one?

I know that same mail is not something clear, it can get defined with many combinations (same description-same body, same time-same description etc). Thank you in advance.

Upvotes: 0

Views: 39

Answers (1)

Nick
Nick

Reputation: 5042

You can't reliably.

To try to make it work, when you move an e-mail, you can store the original mail id into a custom tag field in the new e-mail you create in the target folder (when you move an e-mail, you actually create a new e-mail message with the same content, but the mail id will be different). Then, before you save the message in the target folder, search the target folder for a message with a custom tag that matches the id of the original message.

This approach will not work 100%. You still have a race condition when the add-in, working for multiple users simultaneously, perceives the new message and all add-ins start processing it. Even with a custom tag, it is still possible that two add-ins search for the message in the target folder, both don't find it, and both then store it.

To try to make it more reliable, your add-ins can also periodically clean-up the target folder for messages where this custom tag duplicates.

Upvotes: 1

Related Questions