Tuesday, June 18, 2013

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

}

No comments:

Post a Comment