Prevent the Dynamics CRM Email Router from Processing Old Emails

Zoe Sands, 29 January 2016

Recently I had an issue while setting up the Microsoft Dynamics CRM Email Router, where I was connecting to an existing email mailbox and all the emails were getting pulled through to CRM dating as far back as 2008. This created a lot of irrelevant data and made things difficult for users.

Initial research suggested that setting the Message Expiration field in the Email router configuration could be the answer. "Threshold time after which a message in the mail box is considered old to be neglected in processing." Thanks to this blog explaining the Microsoft.Crm.Tools.EmailAgent.xml file.

While this did not turn out to be the case the solution did in fact turn out to be in editing this file. The MessageProcessingThresholdDays tag in this file is the key. In the configuration file this tag is initially set to -1, indicating to the Email Router that it should process all the emails it finds in the mailbox.

So the steps to fixing the issue of the CRM Email Router processing old and irrelevant email data are as follows:

  1. Stop the E-mail Router service if you haven't already.
  2. Go to the Service folder of the CRM Email Router - C:\Program Files\Microsoft CRM Email\Service
  3. Take a backup copy of the Microsoft.Crm.Tools.EmailAgent.SystemState.Xml and Microsoft.Crm.Tools.EmailAgent.xml XML files.
  4. Edit the EmailAgent file, add this tag <MessageProcessingThresholdDays>X</MessageProcessingThresholdDays> to the <ProviderOverrides> tag, where X is the number of days you want to go back. Save.
  5. Edit the SystemState file, clear everything from between the <State> tags. Save.
  6. Restart the Email Router.

NOTE: it is important to place the MessageProcessingThresholdDays tag in the ProviderOverrides as if you simply edit the existing tags the Email Router will overwrite them when is restarts.