I am sending one email to two address email@example.com and firstname.lastname@example.org and both the address are on TO section. for both the address email 2case has been setup. Salesforce is creating two cases. Is there any way to track the email address for which the case got created.
Let's say, Email-to-Case set up is like this:
And user is sending single email to both the address
So, there are 2 cases will be created and you if see any one of the Email messages, you will find
To Address as
Though for both the Email Messages Parent Ids are different.
I could find querying
Headers from EmailMessage
SELECT Id,ToAddress, ParentId, Headers FROM EmailMessage WHERE Id = '02s7A000008rq3L'
In the Header, search for X-SFDC-Original-RCPT, it shows that particular email address which has been mentioned as
Email Services Addressfor which this case is getting created.