Is there any way that we can add recipients dynamically may be with the help of custom field or any other suggestions.

On button click, it should prompt for mails and those mails should be added to email alert's recipient list based on conditions.

please let me know if you need more details...


Email Alerts reference fields of type Email on the target object or related to the target object

Only in some use cases will the recipients be lists: Account Team, Case Team, Role, Role and Subordinates, Public Groups

Dynamically constructing membership in these lists is not really practical and probably what you don't want anyway

Option 1 - Define 5-10 fields of type Email on your target object; you can hide from the page layout. Then populate those fields with the recipient's email addresses.

The email alert references all 5-10 custom fields; if they are blank at send time, SFDC will ignore

Fragile: Breaks if you need 11 recipients

Option 2 - Send the email from Apex. Then you have complete control over the toAddresses

| improve this answer | |
  • you are right. Will go with Option 2 only because user will enter all the email ids in one text field. I tried all other options. can you please give overview of how it can done. FYI, In this case user click on button and based on some criteria it will sent. Button should work both in classic and lightning – Reddy Mar 13 '17 at 3:06
  • 1
    @Reddy Create a VF page and associate it to a custom button (Classic) and a quick action (LEX). – cropredy Mar 13 '17 at 4:15
  • No need of creating lightning component right.. – Reddy Mar 13 '17 at 8:17
  • @Reddy correct. No lex component – cropredy Mar 13 '17 at 13:58

You can have a VF Page/Flow User Input screen called on a button click. When user enter the email address you can then get those values in the controller through getter/setter. Once you have ToAddress, CcAddress, BccAddress by using EmailMessaging class email can be triggered.

enter image description here

| improve this answer | |
  • i have created a process with 5 different criterias and based on that different email alerts will be sent. Now how can we add this dynamic functionality? – Reddy Mar 9 '17 at 4:39
  • can you site one example of your criteria? – user28452 Mar 9 '17 at 4:42
  • Simple criteria: 1. Suite field value is "travel" 2. suite field value is "airline" – Reddy Mar 9 '17 at 6:45
  • FYI, We cann't use email field as it it allows only one email id – Reddy Mar 9 '17 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.