-1

I want to call Email template in single email method i am using the below code but this is not working. the Query for email template is not working.please check this help will be more appreciated.

My code:

public class singleEmailExample{

public PageReference SendingEmail()
{

 EmailTemplate et=[Select id,developername, IsActive  from EmailTemplate where DeveloperName=:'Recruitmentemail_template'];


List<Messaging.SingleEmailMessage> email = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<string> ToEmailAddress = new List<string>();
mail.settoAddresses(new String[] {'mrachana93@gmail.com'}); 
mail.setSubject('US Departure Process -');
mail.setTemplateId(et.id);


email.add(mail);
mail.SetTemplateid(et.id);

Messaging.sendEmail(email);

return null;
}
}
  • what do you mean by "it is not working"? Are you getting any error messages? – David Cheng Nov 3 '17 at 19:25
  • if the soql isn't working, try it in DeveloperConsole to debug – cropredy Nov 4 '17 at 0:41
0

First you need to check in developer console, to paste this query.

'DeveloperName'='Recruitmentemail_template' is available or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.