I have looked through the site and Google and have come up empty - with such vague terms to search with I am terribly sorry if this has been asked 100 times - if so please point my in the right direction and I'll be on my way...

I would like the ability to use something similar to Email to Salesforce where I can send an email to a specific email address and the email literally gets dumped in a custom object. For instance the custom object would have a to, from, body, cc and bcc fields and I would just dump the body of the email into these fields.

My plan is to then handle these fields using mapping based on common email bodies/content and create rich Leads (better quality than just dumping straight into a lead/case).

Is this possible? If anyone has an example apex class I would rather use that than implement another 3rd party app from the app exchange that i will end up supporting...

But honestly anything will do to get me started :)

=============== EDIT ===============

For anyone who comes across this post, a good place to start would be to read about Email Services:


  • 1
    You should look for email services. This does exactly what you're looking for. You can check out more details about it here developer.salesforce.com/page/…
    – Sam
    Jan 27, 2015 at 6:34

1 Answer 1


There are two possible solutions to this:

Solution 1

Currently when emails are received in Salesforce (using email to case for example) - you have flexibility to assign to queues or users based on some rules, etc. - All emails are created in a record called EmailMessage. This contains all the usual fields you would expect (from, to, headers, dates, message body, etc.). It is possible that you create a trigger on the creation of a new case, take the info from EmailMessage record and map to whatever custom object you want. Of course this assumes that all the info you need is derived from EmailMessage.

Solution 2

The only other way of doing this is to override the standard email Handler. You must create an Apex class that implements the InboundEmailHandler

global class myCustomEmailHandler implements Messaging.InboundEmailHandler {
    //your code to map to custom object

You need to be a bit careful here because you are literally overriding the standard Salesforce email handler. I found this to be a very good article on how to override the standard email handler: http://blog.jeffdouglas.com/2010/03/12/writing-an-inbound-email-service-for-salesforce-com/

  • Solution 2 is exactly what I am after - created an email service to create a dump of the email in a record. Then I will write a trigger to attempt to process the dump based on common body formatting. Thank you! Jan 28, 2015 at 0:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .