Skip to main content

Notifications

Community site session details

Community site session details

Session Id : H8CJa0ksvo7NYrZqDUCDpg
Power Automate - Building Flows
Unanswered

Send an email to various email addresses on multi answer form.

Like (0) ShareShare
ReportReport
Posted on 6 Feb 2024 04:40:54 by 8

I cannot seem to find a straight answer to the following. 

 

I have a form with a question:

 

"Who would you like to send these responses to? "

 

The options are (this is simplified, there are actually dozens of email options, so conditionals wont do):

Bob

Sally

Joe

(multiple answers are allowed)

 

These 3 people have the following emails:

bob@contoso.com

sally@contoso.com

joe@contoso.com

 

(The emails do not appear on the form, I want them hidden from the user)

 

I have compiled a json as follows, but do not understand how to take the choices the user picked, and put them into the TO field of an email. 

 

 

[
{"bob": "bob@contoso.com",
"sally": "sally@contoso.com",
"joe": "joe@contoso.com"
}

]

 

 

So if Bob, and Sally were chosen, then "Bob@contoso.com;sally@contoso.com" should be the appended string which will then go into the TO: field of an email.

 

Doing this in code is trivial, but I can't seem to figure this out with Power Automate. 

 

Thank you!

Jose

  • josedelara Profile Picture
    8 on 06 Feb 2024 at 20:00:03
    Re: Send an email to various email addresses on multi answer form.

    also, for me, the Get Response Details step auto creates an apply to each loop, so mine looks different than yours.

  • josedelara Profile Picture
    8 on 06 Feb 2024 at 18:19:55
    Re: Send an email to various email addresses on multi answer form.

    @v-mengmli-msft 
    IRT the replace string, That makes sense, ty.

    as for the emails, I have a list of users and distribution groups in a JSON file. The user selects from a multichoice question on the form, and there is conditional

    logic in the form based on certain answers that determines who gets an email of form responses. 

    Edit: Unfortunately, that flow did not work. The search users step returns nothing see below, and it's probably because the names in Azure don't quite match the response answers. 


    There must be an easier way to take the name and email value pairs from a json or from a csv and compare them to the multi-select value array. The split worked, though I am not sure how to expand it in the case that I add more names/emails to the question on the form.

     

    also I get this when I use a compose to gather the appended "Email" array:

    [
    "first(outputs('Search_for_users_(V2)')?['body/value'])?['Mail'] ",
    "first(outputs('Search_for_users_(V2)')?['body/value'])?['Mail'] ",
    "first(outputs('Search_for_users_(V2)')?['body/value'])?['Mail'] ",
    "first(outputs('Search_for_users_(V2)')?['body/value'])?['Mail'] "
    ]

     

     

    josedelara_0-1707252409995.png

     

    thank you so much for your help!

  • v-mengmli-msft Profile Picture
    on 06 Feb 2024 at 07:10:30
    Re: Send an email to various email addresses on multi answer form.

    Hi @josedelara ,

     

    I didn't ask clearly. I thought at first that the suffix of the emails was the same. How do you get the User's emails? 'Search for Users' action?

    If so, I recommend you move it in 'Apply to each' to get each user's email according to current item's value.

    Something just like this:

    vmengmlimsft_0-1707202571271.png

    first(outputs('Search_for_users_(V2)')?['body/value'])?['Mail'] 

     

    As for why this formula is used:

    split(replace(replace(replace(replace(QuestionDynamicContent,'[',''),']',''),',',';'),'"',''),';')

    It is because the output of the multi-select value is actually in this string format: ["Option1","Option2"].

    So, if we want to get the email of each option, we need to first convert the output into an array.

     vmengmlimsft_1-1707202875165.png

    This is why I don't modify the array you currently get, because all emails are in an item of an array, rather than each email being an item of the array. This cannot be used directly in Join action.

     

     

    Best regards,

    Rimmon

     

  • josedelara Profile Picture
    8 on 06 Feb 2024 at 06:12:13
    Re: Send an email to various email addresses on multi answer form.
    split(replace(replace(replace(replace(QuestionDynamicContent,'[',''),']',''),',',';'),'"',''),';')

     

    This string is very difficult to read, can you break down the syntax? Why so many nested parentheses? 

  • josedelara Profile Picture
    8 on 06 Feb 2024 at 05:59:21
    Re: Send an email to various email addresses on multi answer form.

    I should have clarified. The names do not match the email prefixes, so a simple join won't work. (that would be too easy :)) 

     

    So it would be more like

    Bob-  robertjones@contoso.com

    Sally - sallyrsmith@contoso.com

    Joe - josephwbrownjr@contoso.com

     

  • v-mengmli-msft Profile Picture
    on 06 Feb 2024 at 05:39:04
    Re: Send an email to various email addresses on multi answer form.

    Hi @josedelara ,

     

    I suggest you convert the result of this question into an array and then use a join action to convert the array into this format: Bob@contoso.com;Sally@contoso.com.

     

    Here is my test for your reference:

    split(replace(replace(replace(replace(QuestionDynamicContent,'[',''),']',''),',',';'),'"',''),';')
    concat(item(),'@contoso.com')

    vmengmlimsft_0-1707197830659.png

    The result of my test:

    vmengmlimsft_1-1707197899435.png

     

     

    Best regards,

    Rimmon

     

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!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,708 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,030 Most Valuable Professional

Leaderboard