I am working on a email to case feature of case . When a customer sends a mail case is created inside our org and now from that case a send a mail(using Send Email Button in related list of case) a mail is sent to that customer and if in return if that customer reply to that mail in that thread with same reference id .. that content does not get attached to that case.. i don't know to implement this functionality.

Thanks in Advance

  • Have u confirmed if you have setup "Email-to-Case" section correctly under Setup | Cases ? – VarunC Feb 6 '15 at 17:52
  • How do i add an inbound email to an existing case ..?? i got the case number from the thread id – user2815826 Feb 6 '15 at 18:42
  • I've added details to do that with proper code highlightings – VarunC Feb 6 '15 at 18:55
  • Have you review the standard SFDC documentation on this? help.salesforce.com/apex/… – CoryCowgill Feb 6 '15 at 19:35
  • 1
    help.salesforce.com/apex/… This explains how the Reference ID works when users send emails directly from Case to End User and how their response gets threaded back to Case. – CoryCowgill Feb 6 '15 at 19:35

Step 1:

You can create a Formula Field on Case (say REF_CODE__c):

"[ ref:" + LEFT( $Organization.Id , 4) + RIGHT( $Organization.Id , 4) + "." + LEFT(Id, 4) + RIGHT( Id , 5) + ":ref ]"

Step 2:

In your Email Template (which you are using to send Emails to customer), you can include the field REF_CODE__c in either Subject or Email Body like this Subject: xyz case subject {!REF_CODE__c} OR in Email Body: just place {!REF_CODE__c} code in anywhere may be end of the email body section.

EDIT: There are many solutions posted over stackexchange itself for computing the Reference Code. One such link is here and there is already an answer marked on this:

Also I found couple of Ideas to support this Reference COde be part of Standard Salesforce Field on Case Object:

| improve this answer | |
  • 1
    Can you please provide where is this documented the format of the Ref Code ID. I'd worry if SFDC changes format of this ID in future will this still work? For example all the folks who hard coded these types of values in their JavaScript based on old SFDC DOM know that stuff like this is subject to change at SFDC's will. If users use the standard SFDC Case Email Response button in SFDC it will automatically attach the REF ID to all emails. – CoryCowgill Feb 6 '15 at 19:40
  • Sry guys, I don't think there is any official documentation to support this .. I'm copying this solution from the information I had gathered in past from a salesforce executive and we've been using this formula nowadays in our crm. And Yes very correctly stated, if however you use Standard Reply button on Email on Case, SFDC will attach this code. I'll be updating the answer with more information about this formula evaluation. Thanks for querying on this @CoryCowgill :-) – VarunC Feb 6 '15 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.