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
KD9500KD9500 

Mass Email examples

Hi,

 

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.

 

Thanks

Krishnadas M R

KD9500KD9500
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(){
selectedApplication.clear();
for(jobappwrapper jawrapper : jaList)
if(jawrapper.selected == true)
selectedApplication.add(jawrapper.jap);
return null;
}


public List<Job_Application__c> GetSelectedApplication(){
if(selectedApplication.size()>0){
return selectedApplication;
email = [select Candidate__r.Email__c from Job_Application__c];
}
else
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.setTargetObjectIds(toMassTargetObjects);
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.

 

Thanks

Krishnadas M R

knightknight

no you cannot

Venu EVenu E
Hello,

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 -  https://goo.gl/wvcZ3P

Do you want to know more details click here https://goo.gl/e0RtSm

Regards
Venu E