In Previous article, I have explained that how to configure Email to Case Agent for creating of cases in Salesforce. This article depicts how to troubleshoot few common problems of Email to case or On Demand Email to Case.
Q 1 : Why reply to email is also becoming new Case instead of Comment on existing Case?
Ans : We need to include {!Case.Thread_Id} field in Subject line or body then only it will be added in “Open Activity” Section.
Also, Go to “Setup | App Setup | Customize | Cases | Email-to-Case “. There is a section on the Email-to-Case Settings page that says: “When sending email from a case, insert Thread ID in the following sections:” make sure that there is a check for Subject and Body. This will place a ThreadID on the email being sent from the Case. The ThreadID is a reference number that gets checked when coming back into Salesforce and will route itself to the right Case instead of creating a new one.
Q 2 : I want reply added as Comment but not as Activity in Email to case. How to do this?
Ans :
A workflow rule + an apex trigger would work.
- Make a custom field on Case called “last email.” Don’t show it on any page layout.
- Make a workflow rule on Email Message which copies the text of the email to that field.
- Make an Apex trigger on Case which takes that field and makes a new comment out of it.
trigger commentMove on Case (after update) { Case myCase = trigger.new[0]; if (myCase.Last_email__c!= null) { String caseId= myCase.ID; CaseComment cc = new CaseComment(CommentBody=myCase.Last_email__c,parentID=caseId); insert cc; } }
Q 3 : I want to break Auto Reply (Out of Office Message, On Leave Message) to Auto Response for Email to case. How to achieve this?
Ans : There is exactly no full proof solution to this problem but we can try to check if reply is coming on Same day (We can also check if reply is coming in 5 minutes or 10 minutes). Below Trigger will help to break this loop if there are atleast 4 emails and last email was less than 5 minutes:
trigger LoopKiller on Case (before insert) { /* * Email Loop Killer * Will not process new email if there are atleast 4 emails from * the same email with the same subject and the previous email was less than 5 minutes ago */ case[] c = trigger.new; case[] check = [select ID, CreatedDate, subject from Case where SuppliedEmail = :c[0].SuppliedEmail and subject = :c[0].subject and isclosed = false order by CreatedDate desc]; system.debug(c[0].SuppliedEmail); system.debug(c[0].subject); if(c[0].Subject != null) { //We have a subject, proceed. if(c[0].subject.contains('[ ref:')){ //No Errors. Email should be attached to the case. }else{ if(check.size() > 3){ if((check[0].createddate.addMinutes(5) > System.now()) && check[0].subject.contains(c[0].subject)){ c[0].addError('Automatic email loop has been terminated'); //Loop Was Killed. }else{ //New Case should be created now! } } } } }
Youtube Video Tutorial of Email to Case Agent:
Leave a Reply to JitendraZaaCancel reply