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
MATTYBMEMATTYBME 

Documentation on how to Implement Email Services to post to a Case?

I am struggling to find sufficient documentation surrounding email services to submit to a Case. Can anyone point me in the right direction please?
Best Answer chosen by Admin (Salesforce Developers) 
MATTYBMEMATTYBME

Thank you both. Werewolf's suggestion was an easier configuration. I just needed to get all the information I could find in order to understand what to do.

That done I will attempt to break it down in laymans terms to hopefully provide some help for those as confused as I when I got started.

Instead of the old way of having to set up the Email-to-Case applet on your email server there is a much easier way; Email On-Demand Service.

 

First you need to set up your Email-To-Case settings.

You need to specify the particular settings you require but for this example I picked the minimal settings. Make sure that "Enable On-Demand Service" is checked.
 
Next hit the New button for the Routing Addresses.
 

All Answers

shillyershillyer

Have you reviewed the Online Help and Email to Case page?

 

Hope that helps,

Sati

MATTYBMEMATTYBME
Yes I have. Wholly inadequate.
shillyershillyer

Are you trying to setup Email to Case with the agent or through Apex Email Services?

 

Where exactly are you stuck?

MATTYBMEMATTYBME
At the creation of the Apex class for the Email Service.
shillyershillyer

Take a look at this example. It generates a task from an email, but you can apply this to creating a case.

 

Hope that helps,

Sati

MATTYBMEMATTYBME
Thanks. Saw that too. Helps if you know Apex well enough. Unfortunately I don't. Oh well I will try something but if you know of how to repurpose the task example for Cases I would be greatful.
shillyershillyer

Ask and you shall receive. I updated the example to work for Cases. One thing I encountered that could have been affecting you is that the Task (or Case for me) was not created if a Contact with the same email address that I'm sending from was not in the database. Therefore, I've updated the code to allow the Case creation even if the email address doesn't already exist. If it does, it finds the related Contact and associates it to the Case.

 

global class cases implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env){ // Create an inboundEmailResult object for returning // the result of the Force.com Email Service Messaging.InboundEmailResult result = new Messaging.InboundEmailResult(); String myPlainText = ''; // Initialize the Contact ID, so if no Contact is found, a case is still created ID vconID; // Add the email plain text into the local variable try { myPlainText = email.plainTextBody.substring(0, email.plainTextBody.indexOf('<stop>')); } catch (System.StringException e) { myPlainText = email.plainTextBody; System.debug('No <stop> in email: ' + e); } // new Case object to be created Case[] newCase = new Case[0]; // Try to lookup any contacts based on the email from address // If there is more than 1 contact with the same email address // an exception will be thrown and the catch statement will be called try { Contact vCon = [Select Id, Name, Email From Contact Where Email = :email.fromAddress Limit 1]; // Add a new Case to the contact record we just found above - if not Contact found, value remains null vconID = vCon.ID; // Insert the new Case and it will be created and appended to the contact record System.debug('New Case Object: ' + newCase ); } // If there is an exception with the query looking up // the contact this QueryException will be called. // and the exception will be written to the Apex Debug logs catch (System.QueryException e) { System.debug('Query Issue: ' + e); } newCase.add(new Case(Description = myPlainText, Priority = 'Medium', Status = 'New', Subject = email.subject, ContactId = vconID)); insert newCase; // Set the result to true, no need to send an email back to the user // with an error message result.success = true; // Return the result for the Force.com Email Service return result; } static testMethod void testCases() { // Create a new email and envelope object Messaging.InboundEmail email = new Messaging.InboundEmail(); Messaging.InboundEnvelope env = new Messaging.InboundEnvelope(); // Create the plainTextBody and fromAddres for the test email.plainTextBody = 'Here is my plainText body of the email'; email.fromAddress ='shillyer@salesforce.com'; Cases caseObj = new Cases(); caseObj.handleInboundEmail(email, env); } }

 

 

Hope that helps,

Sati

werewolfwerewolf

You don't even need to write any Apex code anymore.  You can use Email To Case as a Service, which will automatically generate the Email Service for you.

 

See the blog post about it here.

MATTYBMEMATTYBME

Thank you both. Werewolf's suggestion was an easier configuration. I just needed to get all the information I could find in order to understand what to do.

That done I will attempt to break it down in laymans terms to hopefully provide some help for those as confused as I when I got started.

Instead of the old way of having to set up the Email-to-Case applet on your email server there is a much easier way; Email On-Demand Service.

 

First you need to set up your Email-To-Case settings.

You need to specify the particular settings you require but for this example I picked the minimal settings. Make sure that "Enable On-Demand Service" is checked.
 
Next hit the New button for the Routing Addresses.
 

This was selected as the best answer
MATTYBMEMATTYBME

This is where you specify a routing address, the example is a fictional email address but would be your support  emailsupport@support.com email address. I won't explain all the features here but you may want this routing address to be used for only one clients Cases; meaning you only want one client to be able to use his/her email address to route emails sent via the routing email address emailsupport@support.com that will in turn create a Case from the email. If this is so just include that one clients email address in the "Accept Email From" box. If you want this email routing address emailsupport@support.com to be used for all email sent to that address leave this box blank.
 
Take into consideration what Case Record Type you want the emails through this routing address to use for the creation of the Cases. This only applies if you have more than one Case Record Type.

 

Select Save. A dialogue box appears.

MATTYBMEMATTYBME

The system then needs to verify the routing address so this mailbox email routing address emailsupport@support.com would get an email asking for verification. Once verified you need to set up a message redirect/forwarding rule in that mailbox (You can do this in whatever Email client you use. I tested it on my Gamil and all you do is go into settings and then forwarding. See Image)

 

 

 The forwarding email address is the Salesforce Email Services Address, example emailsupport@d-tt50q25m5057qrx97z46gp4i.in.salesforce.com  
 
Once this is done you would need to tell your clients to send their support emails to our emailsupport@support.com address and when they do Salesforce will convert those email into Cases. Your normal Assignment, Workflow and Validation Rules would work as per normal.
 
Hope this helps! 

nicksquashnicksquash

thanks for the detailed info.

 

I have a few questions I was hoping someone could answer:

 

 1. What is the limit on email attachments and how do we define how these are handled?  (at the moment it just sends an email to me, the sys admin, with an error saying "MAXIMUM_SIZE_OF_ATTACHMENT : attachment data exceeded maximum size")

 

 2. The emails sent to the customer as part of the auto-response rules are now being included in the Emails section of the case.  How do I stop this from happening?

 

 3. Is there some logic in place that stops an auto-response to auto-response infinite loop?  ie. If my auto-response is sent to another companies email which auto-responds to us, and then starts playing auto-response tennis.

 

cheers

Nick

nicksquashnicksquash

In response to question 1 in my previous post, I've worked out the limit is 10MB for attachments but don't know if there is a way to define other ways to handle a large attachment.  perhaps it's just a matter of going to the actual email in the inbox (ie. outside of Salesforce).

 

I also did a test with 4 attachments, each one less than the 10MB limit but a total of about 23MB.

The forwarding of the email to the Salesforce address bounced back to the forwarding address (not the customer) and the bounce email didn't get forwarded on.  this means that no information was lodged in Salesforce so we wouldn't normally be aware that it has bounced.

 

Also, is there a way to reduce the limit?  

We're always running low on storage space, so this would be handy.

paul-lmipaul-lmi

RE: Auto-replies....good luck.  We've been fighting that battle since Apex Email Services was released last year.  I implemented Apex Email Services for this as soon as it was available, and because there's no RFC standard for hwo an email auto-reply should be crafted, there's no standard way to discard them.

 

RE: Spam, if anyone is looking for an answer there, that answer is you have to handle it yourself.  Using Gmail as an inbound "proxy" for email does well for us, but it's nowhere near perfect.

 

raghu.cheruvuraghu.cheruvu

Our email to case is not working whereby the emails are appearing in outlook but they are not generating a case in Salesforce. what might be the reason

Red_WizardRed_Wizard

Are there any suggestions to handle more complicated processes for email to case? For example if a company wanted to use email to case to handle error and exception emails thrown by outside systems. Each error or exception is first triaged by a development team, if the team determines the error needs to be routed and resolved by another department or done later they want to send the email to Salesforce to open the case. However I am having a hard time because some errors have to have department teams. I feel this will get to hard to manage and too complicated when there could be a simpler way to handle it.

 

Basically this is the run down:

 

1. Email Distro: cscase@company.com

    Case assigned to Customer Support

 

2. Email Distro: Caseteam@company.com

    Case assigned to Team 1

 

This would be repeated for every instance the individual department would change and teams of departments. We are talking about 5 different departments with any number of teamed combinations.

tthomas3tthomas3

I am trying to figure out how to get the confirmation code sent to me to update Gmail in this case.  How do you do that when the mail address you are forwarding to is velocityhall@v-jc6iromp9u9y6nlbg9ta60j2.w-cepmaa.w.case.sandbox.salesforce.com