Using a Email Service - Email2Anything

We have created several email services over the last few months. I thought I would mention how this cool functionality in can be put to work for you.

An email service is a system in that gives you an email address to which you can send emails that you want handled by in some way. The "handling" of the email is through custom APEX code that gets executed when an email is received at that address. You might need:

Email2Lead (Email to Lead)
Email2Contact (Email to Contact)
Email2Opportunity (Email to Opportunity)
Email2Anything! (Email to Anything else!)

If you want to send an email to and have it handled in a special way. Then the email service is the way to make that happen.

Inbound Email Service Requests

We used an email service in the Snapptraffic instance of Salesforce to handle help requests that come to us from our clients. When a client sends an email to our help request email address with a description of a problem that they need solved, we have code that does a search for their email address (through all the Contact records) and upon finding it creates a new "Request" record, associates it with the contact record, sends a reply to the contact, and informs their account manager that a new request is waiting for them. It also creates activity records with the email details. One other cool thing we did was include an "Request ID" in the subject line of any emails so that our code could associate inbound emails with existing requests rather than create new ones.

(You may be wondering why we didn't just use cases which has a lot of this functionality already in place. My Snapptraffic reps are on Platform licenses of Salesforce rather than full Enterprise Licenses. Platform licenses are typically under $50/mo rather than $125/mo for Enterprise - but Platform licenses have access to Accounts, Contacts, and any custom objects, but not standard objects like Leads, Opportunities, Cases, etc - so I created a custom object to handle Requests and an email service to mimic the cases functionality)

Email2Lead - Emails from Lead Sources such as Brokers

Another common request that we've built for clients recently is variations on "Email-to-Lead" (Email2Lead, Email to Lead, whatever people want to call it). has no provision for this, but an email service can easily be written to provide this capability.

The way we've implemented it is to allow the user to forward an email received from a new prospect into the email service and have the system create a new lead record based on that inbound message. We normally include "switches" in the email body whereby the user can provide some direction to the code to ask it to do certain things. For example, the user might want to populate fields on the Lead with data not discernible from the common email fields such as subject, to, from, etc - like possibly the Industry field. So we'll give the user the ability to add lines to the body like:

Industry: Communications

Our code will parse for these switches, then populate the lead fields accordingly. Some clients use many of these switches. The code then creates the lead record, sets all those fields, can auto-reply to the lead, and make any other necessary records (like activity records based on the email). One client uses a selectable "signature" with all of these switches embedded and they can quickly add the details they want before sending the email.

Email to Opportunity

One client wanted to be able to forward emails from existing clients and have the email service create a new opportunity. We used switches just like in the above example so that he could set any fields on the opportunity he desired by typing the name of that field and the value he wanted in it, like:

Amount: $25,000
Type: Existing Business

The email service finds the correct Contact record (based on the email address), then creates a new Opportunity for the Account to which that Contact is associated and sets the fields of the Opportunity according to the switches in the email. 

Handling Attachments

This is also another cool capability of the email service, taking any attachments and doing something intelligent with them. Want them attached to a new opportunity, the contact record, the existing account? Whatever it is, the code can do this.

Variations on "Email to Salesforce"

You've probably realized that Salesforce already has a standard email service called "Email to Salesforce" with some pre-defined functionality that works pretty well. It receives emails that you are sending to your clients from some other email system, like gmail, and finds the relevant lead or contact and attaches that email to their activity history. Many times this system is great right out of the box, but you may want something different. We can create a variation on "Email to Salesforce" and make it do whatever you can dream up.


So the Email Service is a great tool for getting the emails you receive into and handling them in a pre-defined, special way. Contact us at if you want some assistance creating an email service specific to your business model.