gpt4 book ai didi

apex-code - 使用触发器发送带有模板的电子邮件

转载 作者:行者123 更新时间:2023-12-04 07:24:05 25 4
gpt4 key购买 nike

我有以下触发器:

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});
}
}
}

我设法解决了最初的问题,

只是想分享,

谢谢

最佳答案

我设法解决它并发送电子邮件,

我已经更新了代码,

即上面的代码有效

关于apex-code - 使用触发器发送带有模板的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17047778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com