+ Start a Discussion
Oldwen AdrianoOldwen Adriano 

Understanding mail merge or SF email from DEV perspective

Hello,

Is Mail Merge a utility I can use to send emails thru triggers or code?  Or is this just a wysiwyg interface to send a one time email based on templates I create?  In a nutshell, I need to create a trigger that sends an email after a record is updated and incorporate fields from my object into the email.

Thank you,
Oldwen

 

Best Answer chosen by Oldwen Adriano
Agustina GarciaAgustina Garcia
Hi,

You can create an email with Apex code and send it from the trigger. You can find here information about how to do it: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm

However, I DO NOT really recommend you to do it there, because if for any reason the trigger is call in bulk, you will send lot of emails and you can hit a governor limit.

In addition, there are several ways to send an email via the platform. For intance, Process Builder.

After creating an email template, adding the fields you want like I show in this image:

User-added image

You can create a simple Process Builder. Mine send the email if the Account record is created or updated and the Account Number field is "123"

User-added image

User-added image

User-added image

If you don't have an Email Alert, you can create it on the fly (there is a link below the field) and select your email template.

I hope this helps.

All Answers

Agustina GarciaAgustina Garcia
Hi,

You can create an email with Apex code and send it from the trigger. You can find here information about how to do it: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm

However, I DO NOT really recommend you to do it there, because if for any reason the trigger is call in bulk, you will send lot of emails and you can hit a governor limit.

In addition, there are several ways to send an email via the platform. For intance, Process Builder.

After creating an email template, adding the fields you want like I show in this image:

User-added image

You can create a simple Process Builder. Mine send the email if the Account record is created or updated and the Account Number field is "123"

User-added image

User-added image

User-added image

If you don't have an Email Alert, you can create it on the fly (there is a link below the field) and select your email template.

I hope this helps.
This was selected as the best answer
Oldwen AdrianoOldwen Adriano
Thank you for your reply... What is the process builder and where do I find it?

Thank you...
Oldwen AdrianoOldwen Adriano
Hi Augustina,

I was able to find the process builder.  My object that I need to work with is not in the object drop down list.  Can you help me understand why it's not there?

Thank you,
Oldwen
Agustina GarciaAgustina Garcia
Hi Oldwen,

You can find a video about Process Builder here: https://www.youtube.com/watch?v=APiJg7908jk

Also here you can get information about differences between Process Builder and Workflow: https://help.salesforce.com/apex/HTViewHelpDoc?id=process_which_tool.htm&language=en_US (https://help.salesforce.com/apex/HTViewHelpDoc?id=process_which_tool.htm&language=en_US) Actually you would be able to sort yor issue with Workflow as well, although Process Builder is easier to visualize.

Were you able to find your object in the dropdown list? Which is your object? Custom or Standard? In theory all your objects should be available. 

Agustina
Oldwen AdrianoOldwen Adriano
I am not able to find my object.  The object is Lead, which is a standard object I thought.  I am very new to Salesforce.  Any idea why my Lead object is not in the drop down list?

Thank you,
Oldwen
Agustina GarciaAgustina Garcia
I can see Lead in the drop down list. Check your profile just in case you have it disabled

User-added image

But if not, you can do the same with workflow https://www.youtube.com/watch?v=T4N3XDuBvo0 where you can find also Leads:

User-added image

And the process is quite similar
Oldwen AdrianoOldwen Adriano
Ok, thank you.  You have been a great help Agustina.  Thank you for taking the time to reply!!!!!!