1

I have a requirement to send an email to a few users on click of a button on an object. I created an Email Template with merge fields. Then I created a Visual Flow to retrieve the email of all the users that are assigned to another related object with a specific role. I tried to send the email by creating an Email Alert. When creating the Email alert, I noticed that the recipient user needs to be specified in the Email Alert itself. But this does not work for me as I would need to retrieve the Email address of certain users at run time. I need to send the email using HTML formatting with tables. I also saw Send Email in the Flow palette but that uses only a text template. How can I send a HTML Email Template to a collection of recipients from visual Flow?

1 Answer 1

1

First principles of Email Alerts:

  • The recipients have to be fields in the target object (or, in some cases, related objects)
  • For example, fields of type Email, related Contacts, related User fields, the record owner, team members, etc. The allowable fields are shown in the Email Alert dialog that depends on the target object type

So, for Visual Flow, you have some choices:

  • Populate the target object (say, custom fields of type Email) with collected email addresses -- then, workflow or process builder can handle the email alerts.. or ...
  • Call Apex to do the work by sending outbound email (see invocable methods) .. or ..
  • Populate some other custom object EmailProxy__c (one record per email recipient) with each collected email and then have workflow/process builder run on that custom object's creation to send the email alert

Or, some combination of the above

Most likely, if you want HTML table formatting, you will need a VF Email Template and possibly a custom component with its own controller.

2
  • Thank You. I opted to populate the target object with the email addresses.
    – Neema
    Commented Sep 16, 2016 at 17:10
  • Thanks for this response @cropredy - I am trying to solve a similar use case where an HTML Email record is inserted upon another object's Workflow Rule's criteria being met. Would I still need to invoke Apex code for this (is this code I would have to write) or does this exist a class in the SF instance already?
    – GPP
    Commented Aug 22, 2017 at 18:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .