Loading...

Managing approvals, updates, and record changes directly from email can significantly improve efficiency within Salesforce workflows. Instead of logging in, navigating records, and manually updating fields, users can simply respond to emails and trigger automated updates using Email Service in APEX.

This approach is especially useful for businesses leveraging Salesforce automation and looking to enhance user productivity through AI and automation-driven workflows. By using APEX Email Services, organizations can capture incoming email data such as subject, sender, and body, and use it to update records in real time.

In this guide, we will explore how to implement Email Services in APEX, along with a practical use case that demonstrates how Salesforce records can be updated directly through email replies.

What is Email Service in APEX and Why It Matters

Email Service in APEX allows Salesforce to process incoming emails automatically using custom APEX classes. It acts as a bridge between external email communication and internal CRM data updates.

This functionality is particularly valuable in scenarios where quick actions are required without forcing users to log into Salesforce. It supports automation by extracting key details from emails and using them to perform actions like updating records, triggering workflows, or processing approvals.

It will save time of login and redirection of record and then fill and save. To fetch details of replied Salesforce email like from Address, Subject, Body of Email, we will use Email Service in Salesforce.

The case example: We have sent an approval email from APEX to users, now users can approve or reject the approval from email only.

OR

I have sent an email from APEX to user with empty table in its body like below:

Category Revenue
(Fill Amounts)
Profit Margin
Electronics
Services
Maintenance
Spare Components
Services
Total

And now, we want to fill in details on record by replying to the email directly. Below is the entire process of how the Email Service works and the complete implementation of how to send email and get a reply of that sent email:

Step-by-Step Implementation of Email Service in APEX

To implement this functionality, a structured approach is required, starting with creating an Email Service class and ending with sending emails that trigger the service.

Step 1: Create an Email Service class like below example:

Step 2: Create Email Service now.

Emails Service Image 1 1

Just fill in the required fields.

After saving this Email Service class, you will get an option to add Email Address, add the required email address as below:

Email Service Image 2 1

Email Service Image 3 1

NOTE: You may leave the ‘Accept Email From’ field blank to accept email from any domain.

Now, the email address has been generated.

Email Service Image 4 1

Store this address somewhere, so that it can be easily used in APEX class. Create a custom Label to store this address like below.

Email Service Image 5 1

Step 3 : Now create a class to send an email to the owner or any required user of Opportunity to fill the field ‘Next Step’ from email itself only.

To trigger your Email Service APEX class, you have to use the setReplyTo() method of Messaging.SingleEmailMessage.

NOTE: In Subject you can add any field that is unique like AutoNumber field, etc., to specify and fetch the record further to perform actions on it (as an example I am using Id for now).

In Body and Subject, you can use Email Template for better, clear picture and reusability (We have used hardcoded body/subject here just for an example).

The flow of the entire process is like : Opportunity Record Updated with Stage → Email sent to required user —> user replied to email with Next Step message → The message he sent in email has been updated in the Field ‘Next Step’ of Opportunity.

That’s how the email service works.

Watch Live Demo

To extend this implementation further, you can explore how the Email Services Apex Class in Salesforce: Contact Handling and Extraction works in detail, enabling more advanced parsing, contact identification, and data processing directly from incoming emails. This approach helps build more robust and scalable email-driven automation within Salesforce.

No Data Found.

Related Articles
Design and Implementation of Salesforce Jira Task Integration 1 1

Businesses have been using Salesforce for CRM operations and Jira for Agile project tracking. However, without integration, teams manually update both systems, leading to data inconsistency and inefficiency.This mechanism establishes a real-time integration between Salesforce and Jira, allowing seamless synchronization of tasks and agile board statuses.  A custom Salesforce dashboard was developed that replicates Jira-style […]

Read More
Dark Mode in Salesforce Enabling It and Creating Theme Ready Lightning Web Components with SLDS 2.0 1 1

With the Winter ’26 release, Salesforce introduced Dark Mode in Lightning Experience. Dark Mode has been introduced as a beta feature in Winter ’26, and at first it was available only for Starter Edition orgs. It is now rolling out further with Spring ’26 to Professional, Enterprise, and Developer editions. To use Dark Mode, Salesforce […]

Read More
How to Merge and Brand PDF Files in Salesforce Using LWC Visualforce PDF LIB 1

Salesforce developers frequently encounter document automation requirements that go beyond standard Apex-based PDF generation. From merging multiple ContentVersion files to dynamically applying branding like watermarks and headers, traditional server-side approaches often hit Salesforce heap size limits (6MB/12MB), creating performance and scalability challenges. This guide presents a heap-limit-safe PDF merging architecture in Salesforce using Lightning Web […]

Read More
Building a Reusable Popup Modal Architecture in Salesforce LWC 02 1

Modern Salesforce applications frequently rely on popup modals for confirmations, warnings, access control decisions, and destructive actions. However, building modal logic separately inside every Lightning Web Component often leads to duplicated code, inconsistent user experiences, and growing technical debt. This blog introduces a flexible popup modal architecture in Lightning Web Components (LWC) that centralizes modal […]

Read More
How to Add a Lookup Recipient in a Sign Template

This step-by-step guide will provide you with quick steps on how to add a lookup recipient inside a sign template in just a few easy steps. This process improves your eSignature for Salesforce workflow by pulling recipients directly from related records. Whether you rely on Salesforce digital signature features or any eSignature integration, adding lookup […]

Read More
Agentforce VS code

As Salesforce continues to move toward AI-assisted development, Agentforce is emerging as a powerful tool that helps developers interact with their org metadata, objects, and configurations using intelligent prompts. When combined with Visual Studio Code (VS Code) and the Salesforce CLI, Agentforce enables a faster, more context-aware way to explore and build on the Salesforce […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203239658
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
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818