In this blog I am going to walk you through the process of sending an email to multiple users (dynamic in number) like members of a team or contacts of an account in Dynamics 365.
While it is pretty straight forward to send an email to static known list of users using Power Automate Activity Party list by manually hard coding their lookup references
The arduous part is to send email to dynamic multiple users wherein you don’t know the exact count and list of users to whom you need to send an email. Like members of a team or all contacts under an account.
1. Initialize an array variable
2. Retrieve all members of a team (or all contacts under an account) depending on your business requirement
Using the CDS (current) list records connector, query the systemusers entity to retrieve all members of a team using Fetch XML
Here is the Fetch XML query to retrieve all users of a team wherein you have to hard code the team GUID:
3. Append Email “From” User to above variable
Append to the above variable the activity party of from system user in JSON format. We also need to populate all activity parties (From, To, cC, bcC). You can use the following references:
The “From” activity part JSON object looks like this with participationtypemask set to 1:
4. Append Team Members as “To” Activity Party
Now that we have retrieved all team members, we can loop through each of the system user and construct an activity party list for each user and append to above variable. The participationtypemask is set to 2 because all users are “To” recipients in email
5. Create CRM Email Record and Send
Now that we have constructed the list of “From” “To” Email recipients activity parties as JSON object, all we have to do is create email record with this variable listed as activity part and send it.
By clicking at the highlighted option to the right, you can switch the view wherein you can either hard code the email recipients or you can enter the JSON object with activity parties wherein we can construct JSON object with dynamic email recipients.
Send email using bound action.
Happy CRM Em'Powering
*This post is locked for comments