public class EmailClassUtility
{
{
public static void sendmail()
{
messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
list<contact> con = [select id from contact where id ='0036F00002s555oQAA'];
String []toAddresses = new String[]{'XXXXx@gmail.com'};
EmailTemplate objEmailTemplate=[select id, name from EmailTemplate where Name='Custom template'];
email.setTemplateId(objEmailTemplate.id);
email.setToAddresses(toAddresses); // custom email field
email.setWhatId('a0B6F00001crms0UAA'); // custom object id for template
email.setTreatTargetObjectAsRecipient(false); // not send email to contact
email.setTargetObjectId(con[0].id);
Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});
}
}
No comments:
Post a Comment