Bounce emails for Salesforce exceptions when using E2C
Have you ever been to a situation where your customers demands an explanation on why a case was not registered in your salesforce org even when they did what they were supposed to do – sending emails to a valid email-to-case address?!
Within the Case Management, some people might have encountered this scenario where the Customer sends an Email to Salesforce on a registered & verified Email-to-Case Address but for some good reasons (limitations, etc – one of them mentioned below) the Case is never registered in the system. If the organisation has defined an Automated Case User (ACU), that user gets the notification emails for the incoming emails that failed to create cases in the org via Email-to-Case but nothing goes back informing the poor Customer. Unfortunaltely salesforce doesn’t handle this situation quite well as of now.
One of the scenarios:
Someone sends an email with a valid E2C address and along with 100+ emails in the ‘To Address’ field. Now since there is a 4K character limit to this field an exception occurs and the case is not registered in salesforce. As an ACU, I receive an email from salesforce saying STRING TOO LONG: To Address field..(max chr=4000), but nothing was notified to the sender who was happy to raise a case which actually never got raised!
Searching out for some feasible workaround for this situation, I was able to develop a customized solution as described below. Before we checkout the same, lets vote for the Idea here.
Here is how it will work…
Customer sends email to salesforce on a valid Email-to-Case Address, but because of some reason it encounters an exception and a case is not created. At Salesforce, we will build a custom logic using the Email Services to extract the ‘From Address’ of the Customer from the exception email and generating a new Email to be sent to the customer notifying that a case was not created due to an exception requesting to contact may be the Sys Admin.
For the solution, we would need to create the following components:
1. Email Service along with an EmailService Handler Class
2. Custom Setting with data –
a. Subject of the verification email as 'Forwarding Confirmation' b. Email Address for 'Send verification email to' (ACU User's email id) c. Email Display Name
3. Access to ACU user’s Email Settings
Step 1 –
Lets start with setting up an Email Service in the Org. Simultaneously we will need to create a EmailServiceHandler Class. We will use this class for two things:
- To handle the Email Service Verification by the ACU and extracting the From Address (email address of the customer)
- To create a new Email Message for the customer we need to send a notification of the failure/exception
The method mentioned below, extracts the From Address from the Exception Email sent by salesforce.
Finally, generating an Email to be sent back to the Customer.
Step 2 –
At ACU user’s EMail Settings, we need to setup a Forwarding Address and some filters.
Go to Settings > Forwarding and add the Email Service Address (generated while setting up Email Service in salesforce). The email address as used in the code/custom setting field ‘Send Verification Email To’, will now receive an email for verification of the forwarding address. Once a user verify, he may use this address to setup filters for forwarding specific or all emails to this address.
For setting up Filters, go to Email Settings > Filters and create a new filter. You may choose filter as mentioned below:
a. From: Salesforce.com b. Subject: Error (containing the word 'error') c. Keywords: Error, STRING_TOO_LONG (any specific errors keywords)
Now we can add the EmailService Address (the one already added as a forwarding address) in the ‘Send Email to’. Optionally, choose another email on your inbox as well, this helps you to be aware of the actual exception in your (ACU’s) inbox as well.
The only limitation of this solution occurs at the time ACU is changed. If we add a new email address under the Automated Case User, we will need to repeat the Forwarding and Filter setup in the new user’s email settings.
This solution works fine for me and my client. Hope this helps you solve issues at your end too.
If you would like to learn more about makepositive Manage Services please get in touch today!