Its similar to this issue: Email to case:Multiple cases for same email replies
Scenario 1 - When some users sends an email to the email to case, it create a case as expected. When I reply to that loop using Salesforce, I end up inserting the case thread ID on the body. After that every time that a user replies on that thread, all their email goes to the correct case number.
However if customers are sending email to each other, with the email to case on the loop, cases are being created, until one salesforce user finally reply from a case - which adds the case thread id on the body and than finally scenario 1 happens, however lots of cases were already created.
So, how to avoid that?
I've tried to use the EmailMessage ThreadIdentifier field, which contains the ID of the loop thread. On the before trigger on EmailMessage object, I would check if there is any other EmailMessage with the same ThreadIdentifier and if there is, I would point the new email to the same existing case and delete the recently created case (which was just created by the new email). However the ThreadIdentifier is null on the before trigger... So I'm still looking for a workaround for that.
Do anybody suggest anything? Thanks!