+ Start a Discussion
sfdc freshersfdc fresher 

send the email to related contacts of accounts in batch as part of Finish method

Hi all,

I have a requirement like: Whenever the Accounts are updated , related contacts should get the mail from Finsh method in Batch apex.

Could you please help me in this. 

thanks,
Padmavathi Ch
NagendraNagendra (Salesforce Developers) 
Hi Padmavathi,

May I suggest you please check with below link from the forums community with a similar discussion which might help. Please let us know if this helps.

Kindly mark this as solved of the reply was helpful.

Thanks,
Nagendra
 
sfdc freshersfdc fresher
Hello, 
am using below code, email sent to targedtted contacts,but unable to see Email temple for that contacts.Where can I check these contacts?


public class MassEmailMessagingApex{
    

    public void SendEmail() {
   List<contact> lstcon=[Select id from contact limit 2];
   List<Id> lstids= new List<Id>();
   for(Contact c:lstcon) {
  lstids.add(c.id);
 }
 EmailTemplate et=[Select id from EmailTemplate where name = 'CourseName_Fee' limit 1];
 
 Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
 mail.setTargetObjectIds(lstids);
 mail.setSenderDisplayName('System Admin');
 mail.setTemplateId(et.id);
 Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
}
    }