7
發送電子郵件模板,我有以下觸發:使用觸發
trigger send_notification on Inquery__c (after update) {
Inquery__c inquery = trigger.new[0];
String[] toAddresses = new String[] {inquery.email__c};
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(inquery.OwnerID);
mail.setSenderDisplayName('Salesforce Support');
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
if (Trigger.isUpdate) {
if(inquery.Quilification__c == 'Qualified') {
EmailTemplate et=[Select id from EmailTemplate where DeveloperName=:'Invitation_to_register_for_Class'];
mail.setTemplateId(et.id);
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
if(inquery.Quilification__c == 'Disqualified') {
EmailTemplate et=[Select id from EmailTemplate where DeveloperName=:'Ineligible_course_candidate'];
mail.setTemplateId(et.id);
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
我設法從原來的問題解決此問題,
而只是想分享,
感謝
什麼樣的模板是'Invitation_to_register_for_Class'?它是自定義,HTML,文本還是VisualForce?我試圖讓VisualForce模板起作用,但是我無法通過工作流或觸發器使其工作。我收到一封空郵件。 – IanT8