Posts

Showing posts from 2018

Email Messaging from Salesforce

SingleEmailMessage  &  MassEmailMessage  classes are provided by Salesforce, which can be used to send an email or email in bulk to the users. First of all we need to create a  Helper class ,we will call this class using Trigger, whenever the condition met, the trigger will call this Helper class, and all the stuffs whatever we are doing, will be in helper class. We are using an email template too. Here is the Helper class named  "HelperContactTrigger" public with sharing class HelperContactTrigger { //static method public static List  sendEmail(List  contacts) { //query on template object EmailTemplate et=[Select id from EmailTemplate where name=:'Sales: New Customer Email']; //list of emails List  emails = new List (); //loop for(Contact con : contacts){ //check for Account if(con.AccountId == null && con.Email != null){ //initiallize messaging method Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage(); //set object Id