
Announcements
Hi,
How do I send email to user based on a department column value on dataverse? Have a table with name, dept, email address:
| Name | Dept | |
| Test1 | IT | TEST1@abc.com |
| Test2 | HR | TEST2@abc.com |
| Test3 | IT | TEST3@abc.com |
| Test4 | Marketing | TEST4@abc.com |
Based on the above table I need all the users addressed to a single dept to go out as an email from the TO field on email connector. Right now it is picking individual email addresses and sending to departments. Eg.: the email should go to Test1;Test3 for IT on a single email. Appreciate your inputs.
Hi @Teresa24486
I have copied your table into excel, same idea, first part is listing the rows, performing a select action using "text mode" in order to get the dept in an array and then using union in a compose to create a list of unique depts.
2nd stage is an apply to each on the unique departments, filter the list rows array where the dept is equal to current item (i.e. the unique dept 1of 3). Then using a select where the from is the body of the filter and the map (text mode again) is item()?['email'] (you will have to type the expression), you can then join the array of emails with a smie colon and use in an email.
The output is like so:
If you are new to arrays, take a look here https://youtu.be/6nJSUNh579w
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien
P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉