Christmas Special : Upto 40% OFF! + 2 free courses  - SCHEDULE CALL

- Salesforce Blogs -

What is Inbound Email Service in Salesforce?

What are Salesforce Email Services?

Email services are automating the messaging process in salesforce that offers secure and robust functionality to send emails from the Salesforce. In this Salesforce Email Tutorial, we will discuss email services in Salesforce, Salesforce inbound email handler, Salesforce email integration, inbound email service in salesforce, and outbound email service in Salesforce. 

Types of Email Services in Salesforce

Email messages are a more robust and powerful message exchange scheme in Salesforce. When you have to send or receive some email from external systems then we can use email services in Salesforce. There are two most common types of Salesforce email services as given below and we will discuss each of them in detail in future sections.

  • Inbound email service in salesforce
  • Outbound email service in salesforce

Moving ahead, let us discuss what is inbound email service in Salesforce.

Inbound Email Services in Salesforce

You can use Apex to receive and process email and attachments from the external system to Salesforce. The email is received by the Apex email service and processed by Apex classes that utilize the Inbound Email object. Apex Salesforce email services create an Inbound Email object that contains the contents and attachments of that email. You can use Apex classes to implement the Messaging, Inbound Email Handler Salesforceinterface to handle an inbound Salesforce email message. You can access an Inbound Salesforce Email object to retrieve the contents, headers, and attachments of inbound email messages, as well as perform many functions.

Below are predefined classes

  • Inbound Email Handler
  • Inbound Email Binary Attachments
  • Inbound Email Inbound Envelope
  • Inbound Email Result.

Moving ahead, let us discuss the main methods and properties in Inbound Salesforce Email.

Learn Salesforce in the Easiest Way

  • Learn from the videos
  • Learn anytime anywhere
  • Pocket-friendly mode of learning
  • Complimentary eBook available

Methods/Properties in Inbound Salesforce Email

Here is a complete list of methods used in inbound Salesforce Email.

  • Binary Attachments: A list of binary attachments received with the email if any.
  • CC Addresses: A list of carbon copy (CC) addresses if any.
  • From Address: The Salesforce email address that appears in the From field.
  • From Name: The name that appears in the From field, if any.
  • Headers: A list of the RFC 2822 headers in the email.
  • HTML Body: The HTML version of the email, if specified by the sender.
  • HTML Body Is Truncated: Indicates whether the HTML body text is truncated (true) or not (false.)
  • In Reply To: The In-Reply-To field of the incoming email. Identifies the email or emails to which this one is a reply (parent emails). It Contains the parent email or emails' message-IDs.
  • Message-Id: The Message-ID—the incoming email's unique identifier.
  • Plain Text Body: The plain text version of the email, if specified by the sender.
  • Plain Text Body Is Truncated: Indicates whether the plain body text is truncated (true) or not (false.)
  • Reply To: The email address that appears in the reply-to header.
  • Subject: The subject line of the email, if any.
  • Text Attachments: A list of text attachments received the email if any.
  • To Addresses: The email address that appears in the To

Inbound Envelope Properties

The following are properties for Inbound Envelope.

  • From Address The name that appears in the From field of the envelope, if any.
  • To Address The name that appears in the Tofield of the envelope, if any.

Messaging Inbound Envelope:

This object of this class store the information of the envelope (From address and to address) associated with inbound email.

Read: Zoho vs. Salesforce - CRM Software Comparison for Small Business

Messaging. Inbound Email Result:

The Inbound Email Result used to return the result of the email service. To access email services in Salesforce we need to activate email service

How to Configure inbound email services in Salesforce?

Navigation Setup ->Build->Develop -> Email Services->New Email service What is Inbound Email Service in Salesforce?

  1. Give a name for Email Service Name.
  2. For Apex Class, specify the Apex class you just built
  3. Define the attachment type.
  4. Mention from where we want to receives an email.
  5. Select active.
  6. You can leave the rest of the fields at their default values for starters
  7. Click on save.

What is Inbound Email Service in Salesforce? Click on save What is Inbound Email Service in Salesforce? Any email sent to the above email address will now result in the Apex class being executed. You would typically alias this email address behind one in your own domain.

Salesforce Training For Administrators & Developers

  • No cost for a Demo Class
  • Industry Expert as your Trainer
  • Available as per your schedule
  • Customer Support Available


Apex class
global Class InboundEmailEx implements Messaging.InboundEmailHandler {
publicMessaging.InboundEmailResulthandleInboundEmail
           (Messaging.InboundEmailemail,Messaging.InboundEnvelopeenv){  
Messaging.InboundEmailResult res= new Messaging.InboundEmailResult();
try{
case c= new case();
c.subject= email.subject;
c.Priority='High';
c.Origin='Email';
c.Status='new';
c.Description= email.plainTextBody;
stringemailadd= email.fromAddress;
contact con=[select id from contact where email=:emailadd limit 1];
c.ContactId=con.id;
insert c;
res.success=true;
        }
catch(Exception e){
res.success=false;
     }           
return res;
    }
}

What is Inbound Email Service in Salesforce? Now go to case object What is Inbound Email Service in Salesforce?


Email Attachment Example
global class AttachmentEmailExample implements 
Messaging.InboundEmailHandler{
globalMessaging.InboundEmailResulthandleInboundEmail
(Messaging.InboundEmailemail,Messaging.InboundEnvelope envelope)
    {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
    Contact contact = new Contact();
contact.FirstName = email.fromname.substring(0,email.fromname.indexOf(' '));
contact.LastName = email.fromname.substring(email.fromname.indexOf(' '));
contact.Email = envelope.fromAddress;
insert contact;
System.debug(' Created contact '+contact.Id);
if (email.binaryAttachments != null &&email.binaryAttachments.size() > 0) 
    {
for (integer i = 0 ; i<email.binaryAttachments.size() ; i++)
      {
        Attachment attachment = new Attachment();
        // attach to the newly created contact record
attachment.ParentId = contact.Id;
attachment.Name = email.binaryAttachments[i].filename;
attachment.Body = email.binaryAttachments[i].body;
insert attachment;
      }
    }
return result;
  }
}

Preview

What is Inbound Email Service in Salesforce?

Read: A Guide on How to Get & Reset Security Token in Salesforce Lightning

Salesforce Training For Administrators & Developers

  • Personalized Free Consultation
  • Access to Our Learning Management System
  • Access to Our Course Curriculum
  • Be a Part of Our Free Demo Class

With these simple steps, it is easy to create a salesforce inbound email handler. Moving ahead let us discuss what is outbound email service in salesforce.

Outbound email service in salesforce

Outbound email services are used to send an email to the external system using the Apex code. There are two types of outbound email services in salesforce. These are single email messaging and mass email messaging. As the name suggests, a single email message service is used to send a single email and mass email message service is used to send multiple email messages together.

Here is the syntax for single email messaging in salesforce:

Here is the syntax for mass email messaging in salesforce:

Read: Easy Tips to Clear Salesforce Admin Exam in Just One Attempt

Governance Salesforce email limits

Salesforce has a limit on the number of email messages that you can process in the whole day. If this limit exceeds then the remaining message will jump to the next day for processing automatically. The execution depends on how you configure the failure response setting for each email message either inbound or outbound. Salesforce email limits are calculated by multiplying the total number of licenses to 1000 up to a daily maximum limit of 1,000,000.

When you are sure of Salesforce email limits, let us discuss how to create email services in salesforce.

How to create Salesforce Email Services?

To use email services, go to the setup option then email services option.

  • Click on email service options and create a new email message.
  •  Now create an apex class using an apex inbound email handler.
  •  Check the active checkbox.
  • Now, you can configure the email service to send or receive messages from limited sender or receivers. If you don’t configure this field then leave it empty.
  • Configure the failure response settings.
  • In the end, save the changes you made to particular email service.

Once the email service is created, create an email address for the service from the bottom of the page. An email service can have multiple email addresses attached to it as needed.

Final Words:

This blog for Salesforce Email Integration gives you a sound idea of inbound email services in Salesforce. Here is one detailed example too for your reference to know about Salesforce email limits and Salesforce email services in detail. If you are still confused, signup for our Salesforce training classes online right away and start a never-ending career journey in the IT space.



Salesforce Tutorial Overview

fbicons FaceBook twitterTwitter lingedinLinkedIn pinterest Pinterest emailEmail

     Logo

    JanBask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


  • fb-15
  • twitter-15
  • linkedin-15

Comments

Trending Courses

Cyber Security Course

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models
Cyber Security Course

Upcoming Class

2 days 27 Dec 2024

QA Course

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing
QA Course

Upcoming Class

3 days 28 Dec 2024

Salesforce Course

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL
Salesforce Course

Upcoming Class

5 days 30 Dec 2024

Business Analyst Course

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum
Business Analyst Course

Upcoming Class

2 days 27 Dec 2024

MS SQL Server Course

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design
MS SQL Server Course

Upcoming Class

2 days 27 Dec 2024

Data Science Course

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning
Data Science Course

Upcoming Class

9 days 03 Jan 2025

DevOps Course

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing
DevOps Course

Upcoming Class

1 day 26 Dec 2024

Hadoop Course

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation
Hadoop Course

Upcoming Class

3 days 28 Dec 2024

Python Course

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation
Python Course

Upcoming Class

2 days 27 Dec 2024

Artificial Intelligence Course

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks
Artificial Intelligence Course

Upcoming Class

10 days 04 Jan 2025

Machine Learning Course

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning
Machine Learning Course

Upcoming Class

2 days 27 Dec 2024

 Tableau Course

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop
 Tableau Course

Upcoming Class

3 days 28 Dec 2024

Search Posts

Reset

Receive Latest Materials and Offers on Salesforce Course

Interviews