function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sajjad MussaniSajjad Mussani 

InboundEmailHandler - Email-To-Case - Case Auto Response Rule - How to make it work altogether

Hello
In my org, we already have the standard email-to-case setup. It uses our customercare@mycompany.com email address.
We also have "Case Auto Response Rule" that catches all emails coming to customercare@mycompany.com and sends a templated response with the case id.
Now, I have written a custome InboundEmailHandler to catch all incoming emails, check the subject line and do stuff in code.

Problem/Question:
Instead of creating a new email address to use for this customer handler, I would like to connect this to our main customercare@mycompany.com email address.  Any emails sent to this address should first go through my custom handler and then do email-to-case and Case Auto Response.

Any help would be greatly appreciated
Best Answer chosen by Sajjad Mussani
Danish HodaDanish Hoda
hi Sajjad,
You can call InboundEmailHandler class in the before insert trigger of EmailMessage, this will execute in the same way as you ned.

All Answers

Danish HodaDanish Hoda
hi Sajjad,
You can call InboundEmailHandler class in the before insert trigger of EmailMessage, this will execute in the same way as you ned.
This was selected as the best answer
Swaminathan Gopalakrishnan 8Swaminathan Gopalakrishnan 8
hi Danish, 

am doing similar thing and I see the emailmessage trigger is not getting triggered if i send an email to my company email address from my outlook. 

when i test the same thing from anonymous apex, i could see the trigger getting executed.