You need to sign in to do that
Don't have an account?

how send a email with trigger when a record is conalled ?
hi everyone,
how to send a email with the trigger when a crcord is canclled included some filed with the record like name,address ?
Thanks
AKLKK
how to send a email with the trigger when a crcord is canclled included some filed with the record like name,address ?
Thanks
AKLKK
Here is the sample code
please try this,
{
List<Messaging.SingleEmailMessage> emailList = new List<Messaging.SingleEmailMessage>();
List <Contact> Con= [select id, name from Contact where name =:'Test'];
EmailTemplate et=[Select id from EmailTemplate where Name=:'SFDC TEST'];
for(Contact conObj: Trigger.new)
{
if(conObj.Status=='Canceled') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(Con[0].id);
mail.setSenderDisplayName('Salesforce Support');
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
mail.setTemplateId(et.id);
}
}
}
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
please let us know if it is working or not.