How to send multiple list items in ONE email using Microsoft Flow

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello two days ago I received a question about how to send one email for multiple items from the list as much as it sounds a very simple question it is not that simple and straightforward let's look into that this video is the answer to the question from one of my students as much as it may sound very easy to work with it's not as simple let me show you what you're going to do I have a list inside SharePoint or anywhere else I get the items using get list items now the thing is I want to package the result that I receive from this query in one email and send it to someone it sounds very easy but really it is not let's see the challenges we will face when we try to do this so let's get back to flow and try to query it I go to float at Microsoft comm and I click on create I want to create an instant flow and I do it manually and I call it send list items by email I click on create and there is a button created I add a new step and I want to get the items from SharePoint so SharePoint I get SharePoint and I'm looking for get list items for get items I pick up the list from the SharePoint it's going to be Flo course the list that I want to work with is products so there we go this is the products list my go back here and I save it I don't want to put any filter now if I just run this it will return everything now if I want to send email that contains any one of those let me add a new step here and I call it send email using office 365 and I want to send email and I want to send it to myself user email subject is gonna be products list but here's the thing if I just come to the body and I go under the get items and I select for example title immediately it puts this message inside and apply to each loop and sends one email per item I don't want to do that I want to get the list titles one by one put all of them together in a nice and clean message and then send it this flow at the moment sends me one email per every single item that I have here if the problem is clear let's see how we can handle that obviously this email shouldn't be inside the loop so I just get rid of it delete and we good the message body that should go to someone I'd rather put it in a variable so right in the beginning as soon as the button is pressed I add an action and I create a variable and if I scroll down I will find initialized variable the variable name is going to be list items type is going to be string and the value it can be blank I don't want to put anything here the only thing and remove the space it's going to be easier to handle ctrl C copy and I just rename it it's gonna be initialized list items so far so good I just save it next thing that I want to do now when I'm inside this apply to each that gets the items from get item I want to add every title to this variable add an action and if I go to variables on their variables one of the actions that I have is a pen to a string variable you have to use it because if you just use the set variable you need to make a reference to set the variable its own previous value as much as we love to see it in different programming languages and it works perfectly in almost every programming language it is a working flow so we say append to string variable and this append to string variable is happening inside the loop so for every single item that we add I pick the variable that I have which is list items and the value that I want to append is gonna be item title let me find title here title and right at the end of every item I want to say PR slash so basically a newline and I save it now when I want to send the email I say new step email I need to use outlook 365 send an email I want to send email to the person who is running this flow subject is going to be products in the list and now here I insert the variable which is list items that's it if I see the Advanced Options there is not much to say the only thing that you should keep in mind is that by default this email is HTML so let me just save it and test this flow and see what we get in the mailbox test I'll run it myself save and test continue run flow and so it gets all the items and sends the email here is our mailbox as you can see there is only one email here and if I click on it you see the list of all the products that I had in the list simply I send one email for all the items inside SharePoint it works easily this is not probably the best way there are better ways to do that if I go here inside flow there is another way to do that so instead of concatenating and going through the for each loop we have another control that is called create HTML table that you have it here it directly gets an array and converts it into HTML table but I don't want to cover it here in this one if you really want to see it send me a comment in the comment section and I will show you how to use the create HTML table at the moment this is the easiest way to do that so we read the titles one by one and concatenate it to a string variable and finally we send that string variable all right that was all about it very simple and straightforward as always thank you for watching [Music]
Info
Channel: Alireza Aliabadi
Views: 20,444
Rating: undefined out of 5
Keywords:
Id: 0TpjWPYlxY4
Channel Id: undefined
Length: 8min 11sec (491 seconds)
Published: Sun Nov 17 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.