Today a customer told me, that some mails are not in the queue, but are available in the exchange mailbox. Therefore I started searching. As the whole Server-Side-Sync-Job is just a blackbox, I started to check the plugins and found an error. This caused an exception and therefore blocked the import of the email.
I fixed the bug, but how can I now import the e-mails again?
Each mailbox has a field called ProcessEmailReceivedAfter. This field contains the date and time, the last time the emails where fetched and imported of the exchange mailbox. Based on this field I updated the date to a date in the past.
The next time, the Sync-Job collects the e-mails, all mails starting of this date will be imported. Already imported e-mails in the past will not be imported again, but missing once will be added. Also already imported and afterwards deleted mails in crm won’t be imported again.
I think, that there is a table in the background, which contains the item-Guid of each e-mail. Based on this table, crm can determine, if the email was already imported and if it was afterwards deleted.
If you need the source, to change this field, use this one:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
using (var orgService = new CrmServiceClient(Connection)) { var query = new QueryExpression { NoLock = true, EntityName = CrmObjectConstants.Mailbox, ColumnSet = new ColumnSet("processemailreceivedafter"), Criteria = { Conditions = { new ConditionExpression("emailaddress", ConditionOperator.Equal, "testmail@youmailaddress.com") } } }; var mail = orgService.RetrieveMultiple(query).Entities.First(); mail.Attributes["processemailreceivedafter"] = DateTime.Now.AddDays(-1); orgService.Update(mail); } |