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
nmhnmh 

Mass Email in Visual force

How to send Mass email in visual force. I developed a controller for vf page in which i can send mass email for user. This is working fine for standard email template. But when i use a custom email template id in settemplateId() , i am not able to recieve mail.

The code is as below :

public class testemail
{
User usr= [select Id from User where isActive = true limit 1];
String[] lstStr = new String[]{};


public testemail(ApexPages.StandardController controller)
{
//this.usr=(User)controller.getRecord();
}

public void SendEmail()
{
lstStr.add('shalabh.sharma@accenture.com');
lstStr.add('hemavathi.nm@accenture.com');
System.debug('This is to invoke this method');
system.debug('lstStr --->'+lstStr);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(usr.Id);
mail.setToAddresses(lstStr);
mail.setTemplateId('00X90000000wpKN');
mail.setSaveAsActivity(false);
Messaging.SendEmailResult [] res = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
system.debug('res--->'+res);
}
}

kiranmutturukiranmutturu

try to pass 18 digit id instead of 15

nmhnmh

Thank you kiran, even now i am not receiving the mails .