if new contact is created send welcome email to that contact.if contact is updated send email to that contact like contacts is updated successfully like that in triggers
public class emailSendClass {
public static void emailSendToContact(List<contact> triggernew, string sSubject, string sBody){
// Step 0: Create a master list to hold the emails we'll send
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
for (Contact myContact : triggernew) {
if (myContact.Email != null) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
// Step 2: Set list of people who should get the email
List<String> sendTo = new List<String>();
sendTo.add(myContact.Email);
mail.setToAddresses(sendTo);
// Step 3: Set who the email is sent from
mail.setReplyTo('sirdavid@bankofnigeria.com'); //update it with your desired email
mail.setSenderDisplayName('Official Bank of Nigeria'); //update it with your desired Name
// (Optional) Set list of people who should be CC'ed
List<String> ccTo = new List<String>();
ccTo.add('test@gmail.com');
mail.setCcAddresses(ccTo);
// Step 4. Set email contents - you can use variables!
mail.setSubject(sSubject);
String body = 'Dear ' + myContact.LastName + ', ';
body += sBody;
mail.setHtmlBody(body);
// Step 5. Add your email to the master list
mails.add(mail);
}
}
// Step 6: Send all emails in the master list
Messaging.sendEmail(mails);
}
}
public class emailSendClass {
public static void emailSendToContact(List<contact> triggernew, string sSubject, string sBody){
// Step 0: Create a master list to hold the emails we'll send
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
for (Contact myContact : triggernew) {
if (myContact.Email != null) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
// Step 2: Set list of people who should get the email
List<String> sendTo = new List<String>();
sendTo.add(myContact.Email);
mail.setToAddresses(sendTo);
// Step 3: Set who the email is sent from
mail.setReplyTo('sirdavid@bankofnigeria.com'); //update it with your desired email
mail.setSenderDisplayName('Official Bank of Nigeria'); //update it with your desired Name
// (Optional) Set list of people who should be CC'ed
List<String> ccTo = new List<String>();
ccTo.add('test@gmail.com');
mail.setCcAddresses(ccTo);
// Step 4. Set email contents - you can use variables!
mail.setSubject(sSubject);
String body = 'Dear ' + myContact.LastName + ', ';
body += sBody;
mail.setHtmlBody(body);
// Step 5. Add your email to the master list
mails.add(mail);
}
}
// Step 6: Send all emails in the master list
Messaging.sendEmail(mails);
}
}
apex class :
trigger :
Thanks
let us know if it helps you
All Answers
send me another thing
http://www.sfdc99.com/2014/03/01/sending-emails-using-apex/
Thanks
apex class :
trigger :
Thanks
let us know if it helps you
thanks
https://automationchampion.com/tag/sending-out-an-email-from-process-builder/
in short, create email tamplate and then use it on process builder
thanks
Thanks