cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Combine emails for Checkbox Forms

Good evening,

I would like to ask you for advice on managing a form checkbox with MS Flow. Basically I would like to combine the emails associated with two variables into a single email. Instead it forwards me two separate emails.

 

Alex_1990Z_0-1641409371558.png

Thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions
Jronash
Impactful Individual
Impactful Individual

@Anonymous, were you able to create a spreadsheet or SharePoint list with all of the regions and their related email addresses?

View solution in original post

Jronash
Impactful Individual
Impactful Individual

It's been a busy week, @Anonymous.

 

Ok, I think we can work with the list you've created.  Assuming I understand what you want to do, here's how you could build the flow.

 

First, in your list, don't separate the email addresses with commas.  Instead, put a semicolon on the end of each address.  For instance: test1@gmail.com; test2@gmail.com; test3@gmail.com; etc.

 

Start by initiating an array variable to help you keep track of all the email addresses you will be sending to:

Email1.png  

 

After that, create an Apply to each loop, and have it loop over the REGIONE checkbox array from your form.  (This looks a little different in my flow because I don't have that form field.)

Email2.png

Put your REGIONE checkbox where you see the purple Output in my flow.

 

Next, do a Get Items SharePoint action to get the items from the Regions list you created.  Use the filter query so that it will only return items where the Title matches the current item.  You can reference the current item by using this expression:

item()

 

If you are using the old Get Items action, the Filter Query will look a little bit different:

Email3.png

 

Next, create another Apply to each loop, this time coming from your Get Items Action.

Email4.png

Inside that loop, use an 'Append to array variable' action to add all of the email fields to your variable.

 

Now that you have all of the relevant email addresses in a single array, you need to flatten that array into a string that you can use in your email action.  You can do this by using the join() expression in a Compose action.

Email5.png

I included the whole flow in the screenshot so you can see that my 'Email array to string' Compose action is after the Apply to each loop, not inside of it.

 

In your Compose action, use the following expression to convert your email array to a string:

join(variables('Emails'),' ')

 

Then you can use the output from that Compose action in the To field of your Send an Email action.

View solution in original post

45 REPLIES 45
Jronash
Impactful Individual
Impactful Individual

From your screenshot, I don't see a reason why you would receive two emails unless you get a form response that matches both of your conditions (assuming your other condition also sends an email).

 

You should check the run history for one of the form responses that triggered multiple emails.  Check to see if 

  1. more than one flow was triggered
  2. within each flow, was more than one 'send email' action processed?
Anonymous
Not applicable

In practice, I have noticed that if I enter in CC: the shared email e.g. operazioni@impresa.net and in A: the two reference addresses. I get two emails with the individual contacts as a result. Like this:

- Email 1: To: destination address CC: operazioni@impresa.net
- Email 2: To: destination address (2) CC: operazioni@impresa.net

Instead I should get the following result:

- Email 1: To: destination address; destination address (2) CC: operazioni@impresa.net

Could I integrate functions?

Thank you

 

Anonymous
Not applicable

hi can help me? thx

Jronash
Impactful Individual
Impactful Individual

I don't have enough information to know why more than one email is being sent.  Have you looked through your run history yet?  If you look at the history of a previous run, it should be relatively easy to see if/when multiple emails were sent.

Anonymous
Not applicable

Good evening,

thank you for the support, in practice through the CheckBOX of the regions we have prepared different email contacts. The problem arises when we select multiple regions. I don't want the FLOW to send multiple emails with different contacts. But join them in a single email. Example. If I select the following Regions: LAZIO, LOMBARDIA etc. it is necessary that I send the FORM data a single email. 

 

Alex_1990Z_0-1642358718395.png

 

I would like to avoid creating an email thread for each combination. At the moment, calculating the possible selections of the form. We are about 300 combinations. I would like to avoid posting all of them in the flow.

 

thank you

 

Jronash
Impactful Individual
Impactful Individual

Sounds like your REGIONE data is coming from a checkbox on your form, which would mean that it would be an array, right?  It can contain multiple regions?

 

There are a number of different ways to join an array, but first I'd need to understand how your Regions are matched with the Email addresses where the message should be sent.  Do the email address also come from your form, or are they stored somewhere else in your system?

Anonymous
Not applicable

Hi,

yes they are included on each region, included in the outlook module of flow.
How do I make an array with the REGIONS? it would be perfect because if you select several regions I would have one email with the contacts of REGION1, REGION2 example. Thanks for your support.

Jronash
Impactful Individual
Impactful Individual

Is it possible for you to show me the part of the flow that gets the email address for a region?

Anonymous
Not applicable

sure, here's the flow I do for emails. The array should as a rule understand that you select two REGIONS and send one email, with the contacts of the regionals. Basically of 10 contacts only 2 per region change. Something simple but at the same time complicated 😞

Alex_1990Z_0-1642788065758.png

 

Jronash
Impactful Individual
Impactful Individual

So it looks like you are setting your email addresses by using a lot of conditional statements (IF the region is x, send the email to y).

 

For what you want to do, there will not be a simple way to make this work.  What you need is a sort of dictionary that contains all the regions and the email addresses associated with them.  Think of it as a spreadsheet that has one column for regions and another column for email addresses.  You could build this in a SharePoint list, an Excel spreadsheet, or even in a Compose action if you are familiar with JSON.

 

After you have your dictionary, you can loop through your regions - for each region, filter your dictionary to find the row related to that region, and then take the email address from the same row and put it in a different array.

 

After the loop is completed, you have an array of email addresses.  You can use that to send one email out to every email address in the array.

 

This is a intermediate-level process that we're talking about, so depending on your level of experience, what I've said may not make much sense.  If you're interested in pursuing this, let me know how you would like to build your dictionary and we can take it step by step from there.

Anonymous
Not applicable

Good evening Jronash,

sure would be very cool, the problem that the JSON I am not very experienced. For the email data we can use sharepoint. Thanks, we will update as soon as possible. Regards

Jronash
Impactful Individual
Impactful Individual

@Anonymous, were you able to create a spreadsheet or SharePoint list with all of the regions and their related email addresses?

Anonymous
Not applicable

hi@Jronash ,

 

I have created the sharepoint with contacts, one information the variables with multiple emails in a cell must be divided by the symbol (,)? thanks

 

Alex_1990Z_0-1643221122401.png

 

Anonymous
Not applicable

hi@Jronash ,

do you need more information?

 

thx 🙂

Anonymous
Not applicable

Hi @Jronash , you can help me pls?

Jronash
Impactful Individual
Impactful Individual

It's been a busy week, @Anonymous.

 

Ok, I think we can work with the list you've created.  Assuming I understand what you want to do, here's how you could build the flow.

 

First, in your list, don't separate the email addresses with commas.  Instead, put a semicolon on the end of each address.  For instance: test1@gmail.com; test2@gmail.com; test3@gmail.com; etc.

 

Start by initiating an array variable to help you keep track of all the email addresses you will be sending to:

Email1.png  

 

After that, create an Apply to each loop, and have it loop over the REGIONE checkbox array from your form.  (This looks a little different in my flow because I don't have that form field.)

Email2.png

Put your REGIONE checkbox where you see the purple Output in my flow.

 

Next, do a Get Items SharePoint action to get the items from the Regions list you created.  Use the filter query so that it will only return items where the Title matches the current item.  You can reference the current item by using this expression:

item()

 

If you are using the old Get Items action, the Filter Query will look a little bit different:

Email3.png

 

Next, create another Apply to each loop, this time coming from your Get Items Action.

Email4.png

Inside that loop, use an 'Append to array variable' action to add all of the email fields to your variable.

 

Now that you have all of the relevant email addresses in a single array, you need to flatten that array into a string that you can use in your email action.  You can do this by using the join() expression in a Compose action.

Email5.png

I included the whole flow in the screenshot so you can see that my 'Email array to string' Compose action is after the Apply to each loop, not inside of it.

 

In your Compose action, use the following expression to convert your email array to a string:

join(variables('Emails'),' ')

 

Then you can use the output from that Compose action in the To field of your Send an Email action.

Anonymous
Not applicable

Good evening @Jronash,

 

I have tested the script and it is perfect, but I have a problem maybe I am wrong. Basically the Flow hangs because of this error:

 

Alex_1990Z_0-1643995906400.png

 

I assume that the variable fails to initialise emails. I have followed all the steps and will try to post the stream.

DB_Sharepoint:

Alex_1990Z_1-1643995987631.png

FLOW:

Alex_1990Z_2-1643996173117.png

initialize variable:

Alex_1990Z_5-1643996356410.png

 

Alex_1990Z_4-1643996337150.png

Compose + Email:

Alex_1990Z_6-1643996394690.png

Form

Alex_1990Z_7-1643996465548.png

One thing I have noticed is to initialise the variables: [A] & [CC] with predefined contacts avoiding repeating them in the sharepoint. The dynamic variables are [Regional Manager] & [Chief Territorial Manager].

 

For everything I just have to thank you, I hope that the next module I will be autonomous based on these teachings.

 

 

 

 

 

Jronash
Impactful Individual
Impactful Individual

Hi @Anonymous.

 

I see two problems so far.

 

First, you need to go back through your SharePoint list and put a semicolon after every email address.  Even if there is just one email address in a column, it needs to have a semicolon after it.

 

Side-note:  I'm also confused why you have two list items in your SharePoint list that are both for Umbria.  There should only be one list item for each region, right?  

 

The second issue:  You have your Apply to each loop set to loop over your Email variable, but this is incorrect.  It needs to loop over the REGIONE checkbox from your Microsoft form.

Anonymous
Not applicable

thank you I have reclaimed the sharepoint with unique IDs separated by the symbol [;]. While for the flow issue I have inserted the change. But it keeps giving this error:

 

Alex_1990Z_0-1644011726627.png

maybe it can't identify the region?

Alex_1990Z_1-1644011981056.png

thx for support.

 

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (6,148)