21
JulMonth End Offerl : Get 30% OFF + $999 Study Material FREE - SCHEDULE CALL
You can use email services to process the contents, headers, and attachments to the inbound email. For example, you can create an email service that automatically creates contact records based on the contact information in messages. Email service is using Apex classes to process the contents, headers, and attachments of the email automatically. You can associate each email service with one or more Salesforce-generated email addresses to which users can send messages for processing. The general template to create the apex class for the email services is:
To give multiple users access to a single email service, you can:
To use email services, from Setup, enter Email Services in the Quick Find box, then select Email Services.
Salesforce Training For Administrators & Developers
Read: Top 10 Salesforce Influencers to Follow, Who are Pros!

Salesforce uses two types of email service

Use Apex to work with an email sent from Salesforce. You can use Apex to send individual and mass emails. We can send Salesforce email templates and be in plain text or HTML format, or those generated by Visualforce.
Read: The Ultimate Guide to Salesforce's AI-Powered Solution Einstein GPT!
aSendEmailResult object. The syntax for sending an email is: Messaging.sendEmail(new Messaging.Email[]{mail},opt_allOrNone);
The following are methods for SingleEmailMessage. All are instance methods.
public class outboundemail {
public void myEmail(){
messaging.SingleEmailMessage email1=new messaging.SingleEmailMessage();
string[]toAdd=new string[]{'ganesh.maharana@janbask.com'};
string []ccAdd=new string[]{'subham.singh@janbask.com'};
email1.setToAddresses(toAdd);
email1.setCcAddresses(ccAdd);
email1.setSubject('Greeting from Janbask Training');
email1.setPlainTextBody('Janbask Training Career counselling');
email1.setSenderDisplayName('JanaBask Training');
messaging.Email[] emails = new messaging.Email[]{email1};
messaging.sendEmail(emails);
}
}
Output
Mass EmailMessage We can send a mass email message to a recipient list consists of contact, lead, person’s account or user account are available in Salesforce. Messaging.massEmailMessageMethods: This method consists of three methods.
Example of MassEmail
Read: How to Integrate Quickbooks and Salesforce?
public class massEmailExample {
public void SendEmail()
{
List<contact>conlist=[Select id ,lastName from contact where lastNamelike'g%' ];
List<Id> ids= new List<Id>();
for(Contact c:conlist)
{
ids.add(c.id);
}
EmailTemplate tem=[Select id,name from EmailTemplate where name = 'Sales: New Customer Email' limit 1];
Messaging.MassEmailMessage Email = new Messaging.MassEmailMessage();
Email.setTargetObjectIds(ids);
Email.setSenderDisplayName('System Admin');
Email.setTemplateId(tem.id);
Messaging.sendEmail(new Messaging.MassEmailMessage[] { Email });
system.debug(Email);
}
}
Run Code
massEmailExamplevv = new massEmailExample();
vv.sendEmail();
system.debug(vv);
Output 
Learn Salesforce in the Easiest Way

| SINGLE EMAIL | MASS EMAIL | |
| Multiple recipients? | Yes | Yes |
| Personalized body? | Yes (single body only) | Yes |
| Special permission needed? | No | Yes, has to be enabled |
| Merge fields? | Yes | Yes |
| Personalized merge fields? | Yes (only one record at a time) | Yes |
| Templates? | Yes | Yes |
| Template possibilities? | Text/HTML/Visualforce/Custom Templates | Text/HTML/Custom Template |
Read: How to Create Salesforce Records Type For Custom Objects?
Pinterest
Email
The JanBask Training Team includes certified professionals and expert writers dedicated to helping learners navigate their career journeys in QA, Cybersecurity, Salesforce, and more. Each article is carefully researched and reviewed to ensure quality and relevance.
Gen AI
Agentic AI
AI in Automation Testing
Cyber Security
Data Science
QA
Salesforce Service Cloud
AWS
Search Posts
Related Posts
A Detailed Guide on Salesforce Developer Roles & Responsibilities
14.5k
Top 187 Salesforce Developer Interview Questions and Answers
28k
What Is The Best Way To Grow Your Salary In Salesforce?
6.9k
Salesforce Admin Salary Trends in 2025 | How much do Salesforce Admins Earn
14.7k
Salesforce Certifications Paths- What does the Future hold for Salesforce?
464.8k
Receive Latest Materials and Offers on Salesforce Course
Interviews