+ Start a Discussion
l.trincil.trinci 

Mass email Visualpage

I was looking for a solution on this code:

(The problem is that  the code run perfectly but the email don't come on the email address in any way)

 


public with sharing class MassEmail
{
public List<Applicant_test__c> usr{get;set;} 
public List<String> usr_email{get;set;}
public Map<string,string> Map_usr{get;set;}

public string testemail;



public string gettestemail()
{


usr=new List<Applicant_test__c>();
usr_email=new List<String>();
usr.clear();
usr_email.clear();
usr=[select Email__c from Applicant_test__c where Keep_in_touch__c=true];


for(Applicant_test__c u : usr)
{
system.debug('___________Email______________'+u.Email__c);

if(u.Email__c!=null)
usr_email.add(u.Email__c);
}
if(usr_email.size()>0)
sendmail(usr_email);
return null;
}

public void sendmail(List<String> str)
{
system.debug('dentro il sendmail');
Messaging.reserveSingleEmailCapacity(4);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();


email.setToAddresses(new String[] {'abc@gmail.it'});

String[] toaddress=str;
String[] ccAddresses=new String[]{'abc@tgmail.it'};
email.setSubject('Mass Email');
email.setHtmlBody('Dear Sir /Madam,<br/><br/> Hello <br/><br/>Sincerely,<br><br/><br/>Date :'+string.valueof(system.today()));
email.setToAddresses(toaddress);
email.setCcAddresses(ccAddresses);
Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});


}

 

Thanks

Navatar_DbSupNavatar_DbSup

Hi


Follow the below link for sending the email:

http://boards.developerforce.com/t5/Apex-Code-Development/How-to-send-mass-email/m-p/422021/highligh...

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.