Skip to main content

Notifications

Community site session details

Community site session details

Session Id : kX7nHj9nGH8T7+L9a5noBw
Power Apps - Power Apps Pro Dev & ISV
Suggested answer

Dynamic email recipients based on form value selected

Like (1) ShareShare
ReportReport
Posted on 27 Mar 2025 21:11:23 by 2
Not sure what happened to my previous post. Must've gotten lost.
 
I have set up a power app form where supervisors will be able to send shift reports from a variety of fields. this is tied to a sharepoint list. I have included a button that will submit the form and send an email with the data from the visible form fields to a standardized list of hard coded recipients. I have a separate sharepoint list where i have divided out the recipients for each department where the list looks something like this.
Department Email List
Dept1 user1@ex.com;user2@ex.com;user3@ex.com
Dept2 user2@ex.com;user4@ex.com;user5@ex.com
 
The department field that managers will be selecting from is a multi-select drop down field. The goal is to have an email be sent to users associated with the department(s) selected. If Dept1 is selected, it would send one email to user1@ex.com;user2@ex.com;user3@ex.com. if both of the departments above are selected, one email would go out to a concatenated list of the users like this user1@ex.com;user2@ex.com;user3@ex.com;user2@ex.com;user4@ex.com;user5@ex.com
 
The reason I chose to build the email list in sharepoint is to allow the supervisors to be able to go in and manage who their emails get sent out to without forcing them to copy in the recipients or remember every person they need each and every shift. If it would be easiest to be able to create a custom collection and build based off this, i'm up for whatever would be the easiest route for users. I am new to power apps and am just stuck on this one issue where i've tried different forms of code, but run into an issue where the To: section can't be null.
 
Any help would be appreciated.
  • AM-27032030-0 Profile Picture
    2 on 28 Mar 2025 at 14:51:27
    Dynamic email recipients based on form value selected
     
    Sorry for the multiple posts and for posting into the wrong community area. I posted the first one and checked back and could not see it within my activity files. I'm pretty new to the whole posting to a community thing. Thank you for your reply to this and your patience.
     
    ClearCollect(NewSelectedEmails,Filter('New SPD Email List',DepartmentFrom in Concat(DataCardValue107.SelectedItems,Value)).EmailList);
    This is the code I have started to collect the emails from my list ("New SPD Email List"). I added in your suggestion of wrapping the Department Data card (DataCardValue107.SelectedItems) into a Concat function. I wasn't sure if putting all of this into a ClearCollect function would be the best way to capture the items as I go.  I later reference this collection in the SendEmailV2 action. Both of these code snippets are from the OnSelect property of the button I created. To answer @ronaldwalcott 's question, I am using the connector you referenced as shown below.
    Office365Outlook.SendEmailV2(
         Concat(NewSelectedEmails,EmailList & ";"),
         SPDSubject,
         SPDBody);
     
    The SPDSubject is a variable I sent up at the beginning of the action, right after the ClearCollect I included above. The SPDBody is a rolling variable where I continually add in the data from the visible fields, but skip over anything that is not visible.
     
    Let me know if more information is needed.
  • ronaldwalcott Profile Picture
    3,653 on 28 Mar 2025 at 01:41:02
    Dynamic email recipients based on form value selected
    Are you using the Office365Outlook.SendEmailV2 connector?
  • Suggested answer
    Michael E. Gernaey Profile Picture
    41,934 Super User 2025 Season 1 on 27 Mar 2025 at 22:39:25
    Dynamic email recipients based on form value selected
     
    Its really important that you share your code and what is not working so we can help, plus in this case there isn't any details so writing this is just a pseudo guess.
     
    You have 2 lists.
     
    let's pretend your Combobox is called Department
     
    And let's pretend the List you want to get the the emails from is List2
     
    To get the emails
     
    ONE important detail about the below, depending on how you bound your data to the Department combobox, instead of putting Value, you might have to put the proper column name) 
     
    The below will grab all the records from List2, where the Department Value is in and this is important. the concatenated string of all the things selected in the box
    Filter(List2, Department in Concat(Department.SelectedItems, Value))
    Now, you could do something like (and bare with me I'm eating and one handed typing lol)
     
    // Now I put  'Email List' because you have it in the header with a space. I dont know what the proper COLUMN name is in sharepoint, so please put that, don't put what I typed.
    // again change Value to be whatever matching column you have. If its just a list of Strings in the Items property of the Combobox, then Value is correct.
     
    Distinct(Filter(List2, Department in Concat(Department.SelectedItems, Value)), 'Email List')
    This gives you just a list of the unique values out of email.. and now we want to create the single email string
     
    Concat(Distinct(Filter(List2, Department in Concat(Department.SelectedItems, Value)), 'Email List'),
          'Email List' & ";")
     
    Now one last time, you need to make sure that the proper things are put for
    Value
    'Email List' #1
    'Email List' #2 (this will either be the column name of Value (again lol)
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 14 Super User 2025 Season 1

#2
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

#3
WarrenBelz Profile Picture

WarrenBelz 6 Most Valuable Professional

Overall leaderboard
Loading started