0

我需要在 Scheduled Apex 上通知用户。如何向用户或其他表单或通知发送电子邮件?

4

1 回答 1

2

您可以在此处使用可用于 apex 的电子邮件类。

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'user@acme.com'}; 
String[] ccAddresses = new String[] {'smith@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
mail.setReplyTo('support@acme.com');
mail.setSenderDisplayName('Salesforce Support');
mail.setSubject('New Case Created : ' + case.Id);
mail.setBccSender(false);    
mail.setUseSignature(false);    
mail.setPlainTextBody('Your Case: ' + case.Id +' has been created.');
mail.setHtmlBody('Your case:<b> ' + case.Id +' </b>has been created.<p>'+
     'To view your case <a href=https://na1.salesforce.com/'+case.Id+'>click here.</a>');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
于 2012-10-09T08:37:43.000 回答