Send an Email from Apex Code #inSalesforce

Send an Email from Apex Code #inSalesforce


public class sendEmailExample{
public static void sendEmailMethod(String toAddress, String subject, String body){
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new String[] {toAddress});
email.setSubject(subject);
email.setPlainTextBody(body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});
}
}



Test it from the anonymous window:

String toAddresses = 'tidas69516@fulwark.com';
String subject = 'SampleEmailMessage';
String body = 'ExampleEmailBody';
sendEmailExample.sendEmailMethod(toAddresses,subject,body);

Comments