A primer on the Process

For the uninitiated, the Email Service in Salesforce is an automated Process that strips content bodies, subtext, headers, and attachments from inbound emails for Object creation.

You could go about tieing each Email Service Process to Salesforce-created email addresses meant to receive messages for processing from users of a service.

Alternatively though, to give multiple users access to a service you could associate a single Salesforce email to an Email Service and write a class in Apex to execute differently for each user.

A common use case

As an example, you could write Apex Classes to identify users based-off of their email addresses and create Records accordingly.

Let’s talk Governor Limits

As is often the case with email capabilities, there’re Governor Limits to keep in mind. Here’s a list of them:

  • An email service only processes messages it receives at one of its addresses.
  • Salesforce limits the total number of messages for all email services combined for daily processing, including On-Demand Email-to-Case. Messages exceeding this limit are bounced, discarded, or queued for processing the next day, depending on how you configure the failure response settings for each Email Service.
  • Salesforce calculates the limit by multiplying the number of user licenses by 1,000 and caps out at 1,000,000. For example, if you have 10 licenses, your Org can process up to 10,000 email messages a day.
  • Email Service addresses created in your sandbox can’t be copied to your production Org.
  • For each Email Service, you can tell Salesforce to send error email messages to a specified address instead of the sender’s email address.
  • Email Services reject email messages and notify the sender of the email(comprised of combined body text, body HTML and attachments that extend approximately 10 MB depending on language and character set).
  • Now that you’re a bit more familiar, here is some syntax for you to look at. First of these – is the Email Service.

General syntax for Email Service class in Salesforce

Some more syntax

For our example, we start with the premise that each email’s subject and body contain no more than the words “Create Contact” and the Contact’s name(in that order). Then, in the likeness of an everyday enterprise scenario, we process subject lines to create new Contacts in Salesforce and extract Contact Names from the email body. Attachments come up under the Contact object in sales. In the following sections, you’ll find code implementations and test classes( 75% coverage) for the same.

Apex Class:-

Test Class:-

Defining Email Services with our Apex Class

After creating the above Apex Class, within your instance, go to

<Your Name> | Setup | Develop | Email Services.

Once there,

  • Click New Email Service to define a new Email Service.

Select the Apex Class we just created above, add the email address from where to accept the request and activate the Service as shown below:

After filling out the information, click Save and New Email Address

Next, click Save. This should throw up an email address as shown below.

Note: The domain name in the Email Address must qualify the one entered at Email Service in the first step. For instance, we’ve entered “gmail.com” in the first step, which means it will accept the email address only from gmail.com like the one in the email we just saw.

Finally, once the email address is generated by Salesforce, send the email to that address with the subject line “Create Contact” and a Contact Name as the email body to see if everything checks out.

Conclusion

The codebase here lets you extract data from emails for creating Contacts in your Salesforce Org that could be used to service Contacts from a business account in case of multiple users, especially for helpdesk operations or pushing updates and notifications. You could just as well extend this to build on stores for other objects. For any further assistance with Email feature sets or data extraction solutions for the Salesforce platform, don’t wait to reach out to us at sales@hicglobalsolutions.com

Related Articles
Please Make Blog Banner How to Create an Agentforce Enabled Scratch Org in Salesforce 100 1

Setting up an Agentforce-enabled scratch org is the most important step for developers who want to experiment with AI features such as Prompt Builder and Einstein GPT. Whether you’re developing the next generation CRM software or experimenting with how generative AI may improve user experience, a scratch org equipped with Agentforce is your playground. Follow […]

Read More
Step-by-Step Guide to Enhance Your LWC Development Workflow with the Logger API

Are you looking to streamline your LWC development workflow but confused about how to do it? Then you are in the right place. The Salesforce Logger API is a powerful tool that helps you monitor, debug, and improve code quality in real time.  This step-by-step guide walks you through how to set it up and […]

Read More
Enhancing Your Salesforce Experience with a Custom Activity Component

In today’s fast-paced business landscape, productivity hinges on streamlined workflows and intuitive interfaces. While Salesforce offers robust activity tracking capabilities, sometimes the standard components fall short of specific organizational needs.  That’s where a Custom Activity Component comes in—designed to tailor your activity management experience, boost user efficiency, and provide deeper insights into customer interactions. In […]

Read More
Step-by-Step Guide to Integrating Salesforce Doc-Gen with eSigning Tools

In today’s fast-paced digital landscape, streamlining document workflows is no longer a luxury—it’s a necessity.  Integrating a document generation app, like Docs Made Easy, with an eSigning tool, helps businesses automate the entire document lifecycle—from creation to signature—saving time, reducing errors, and boosting productivity. In this guide, we’ll walk you through the key steps, tools, […]

Read More
How to Build a Real Time Chat Application Using LWC and Models API

The Models API plays a significant role in providing access to and facilitating interaction with large language models (LLMs) from various Salesforce partners such as Anthropic, Google, and OpenAI. It enables applications to leverage these models for various tasks, including text generation and other AI-powered capabilities. As a user, you can configure any Salesforce-enabled model […]

Read More
How to Integrate Salesforce Data Cloud with Amazon Redshift

Companies can finally connect Amazon Redshift to Salesforce Data Cloud without using the ordinary username & password authentication systems ever since its collaboration with AWS has happened. Business owners no longer have to be concerned about managing static credentials or breaching data security. By leveraging Salesforce IDP, companies can easily access their data lakehouse in […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818