Salesforce: Send email from APEX
public class Utility {
public static void sendEmail(String email,String subject,String body,Messaging.EmailFileAttachment attach){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { email });
mail.setSubject(subject);
mail.setHtmlBody(body);
mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
// Send the email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
public static void sendEmail(String email,String subject,String body,Messaging.EmailFileAttachment attach){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { email });
mail.setSubject(subject);
mail.setHtmlBody(body);
mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
// Send the email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
Comments
Post a Comment