function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Mass Email examples



I am trying to send mass email to a list of selected candidates. I have created the list as an Sobject and passed the email addresses to it. I am not sure how to pass this list to the target id in the mass email. Some examples would help me.



Krishnadas M R

The apex code is as follows. 

public class massemailapplicants {

Candidate__c candidate;
Job_Application__c jobapplication;
List<jobappwrapper> jaList = new List<jobappwrapper>();
List<Job_Application__c> selectedApplication = new List<Job_Application__c>();
List<Job_Application__c> email = new List<Job_Application__c>();

public List<jobappwrapper> getjobapp(){
for(Job_Application__c ja : [select name, Candidate__c, Position__c, Candidate__r.First_Name__c, Candidate__r.Last_Name__c, Candidate__r.Email__c from Job_Application__c ])
jaList.add(new jobappwrapper(ja));
return jaList;

public PageReference getSelected(){
for(jobappwrapper jawrapper : jaList)
if(jawrapper.selected == true)
return null;

public List<Job_Application__c> GetSelectedApplication(){
return selectedApplication;
email = [select Candidate__r.Email__c from Job_Application__c];
return null;

public class jobappwrapper{
public Job_Application__c jap{get; set;}
public Boolean selected {get; set;}

public jobappwrapper(Job_Application__c ja){
jap = ja;
selected = false;

public PageReference Rejected() {
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
String toMassTargetObjects [] = {email};
mail.setSubject('Apex Sharing Recalculation Exception');
mail.setPlainTextBody('The Apex sharing recalculation threw the following exception:');
Messaging.sendEmail(new Messaging.MassEmailMessage[] {mail});
return null;


 Please point out what am i doing wrong.

Can we send a mass email to list other than contact, Leads and users.



Krishnadas M R


no you cannot

Venu EVenu E

Your email marketing goals don’t slow down for Salesforce send limitations, so why should you? Send the amount of emails that you need when you need with ease. You campaigns go out as needed when you use MassMailer to break free of the inherent hurdles set in place by Salesforce.

You can play with this app free trail for 15 days -

Do you want to know more details click here

Venu E