Salesforce - Developer - Sending Email

salesforce-developer

// Salesforce - Developer - Apex - Sending email:

public class sendEmailClass {
  String subject {get; set;};
  String emailBody {get; set;};
  public PageReference send() {
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    email.setSubject(subject);
    email.setPlainTextBody(emaiBody);
    List<String> emails = new List<String>();
    emails.add('toaddress1@somewhere.com');
    emails.add('toaddress2@somewhere.com');
    email.ToAddresses(emails);
    Messaging.sendEmailResult[] r = 
      Messaging.sendEmail(new Messaging.singleEmailMessage[]{email});
    return null;
  }
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License