I would like to send an email by using email template before delete a specific record. I'm using a before delete trigger and I receive the email, the problem is that the email is almost empty, without any record details. The same email template is used for after update and it works fine (record details are correctly sent). Any suggestions?
trigger opportunityNotificheOAS on Opportunity (before delete, after update) {
if(Trigger.isDelete){
for(Opportunity o : Trigger.old){
emails.add(prepareEmail(o));
}
}
In the prepareEmail method I do the following:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(et.id); mail.setTargetObjectId(c.Id); mail.setWhatId(o.Id);