+ Start a Discussion
sfdclivesfdclive 

sending emails automatically on schedule basis

Hi,

I created some distrubution lists using custom settings, in each distribution list i have email field,created 10 records for each distribution list,.

 

I need to send automatic emails based on email templates on scheduled base.

 

 

please help how to write code for this

 

Best Answer chosen by Admin (Salesforce Developers) 
abinayaabinaya

Here is the sample code 

List<Candidate_Mapping__c> AssgnCand = new List<Candidate_Mapping__c>(); 

for(Candidate_Mapping__c  acan: [Select Manager_Email_ID__c,LR_Email__c,R_email__c,MR_Email__c from Candidate_Mapping__c where id=:id ])
    {
         manageremail = acan.Manager_Email_ID__c;
         system.debug('manageremail :' + manageremail );
         lremail = acan.LR_Email__c;
system.debug('lremail :' + lremail );
         remail = acan.R_email__c;
system.debug('remail :' + remail );

}

 toAddresses = new String[]{manageremail,remail ,lremail }; 

All Answers

sfdclivesfdclive

Hi,

 

Here my doubt is how to declare that custom setting(custom object) in toaddress.

 

i need to send emails to all emails of the custom object(distribution list)

 

regards

sri

abinayaabinaya

Here is the sample code 

List<Candidate_Mapping__c> AssgnCand = new List<Candidate_Mapping__c>(); 

for(Candidate_Mapping__c  acan: [Select Manager_Email_ID__c,LR_Email__c,R_email__c,MR_Email__c from Candidate_Mapping__c where id=:id ])
    {
         manageremail = acan.Manager_Email_ID__c;
         system.debug('manageremail :' + manageremail );
         lremail = acan.LR_Email__c;
system.debug('lremail :' + lremail );
         remail = acan.R_email__c;
system.debug('remail :' + remail );

}

 toAddresses = new String[]{manageremail,remail ,lremail }; 

This was selected as the best answer
sfdclivesfdclive

Hi,

please need some clarification.

 

shall we declare our custom settings(custom Objects) in excecute method.

 

Regards

Sri.