Count Email Attachments and Add to SharePoint list with Power Automate

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone welcome back to another video here on YouTube working again with power automate this time what we're gonna check out is how we can count attachments that come into our inbox using Office 365 Outlook [Music] alright so here we are just getting started with a flow using Microsoft's power automate here in the cloud what I have set up thus far is my trigger that's going to monitor my inbox and then when it's going to run is when I make sure I have attachments so one of the things you want to enable is to show your Advanced options here and set up to make sure that you do include attachments and to make sure in this case I'm going to say only with attachments because the purpose of this flow is to go ahead and count those attachments now the next step that I have in here as well is I've just added in a subject filter to this to make sure that it's only going to run for specific emails that I get based on that subject filter you can do that by adding it you know a filter from who it's from or anything else but in this case I'm just going to go with the basic subject filter and then what I've done was added in a variable now working with variables here in power automate it's really important to make sure that you are naming your variables properly so you can let yourself know later on what exactly that variable is intended on doing and how we are going to use it later on in this case the variable that I have initialized here is called attachment count I'm going to use that because I'm going to try to count the attachments that I have coming in for each email so you can see here that my type is of an integer and we're starting off with a value of zero which means that we'll be starting with no attachments and we're going to count from there up one each time in order to see how many attachments we actually have now the next step here is to go ahead and get all of the attachments in order to count them with our our flow here so the next step I'm going to add in here is an action from Office 365 Outlook called a get attachment I'm going to use this in order to make sure that I can actually capture all the attachments yes we do have the dynamic content from when an email arrives to look at the attachments but this isn't going to be a little bit better if I want to add this in to say you know maybe a SharePoint site or into an Excel document or a dataverse table if I want to add in any information including that attachment by using get attachment it's going to be the best way in order to actually see the full data of that attachment so if when we choose get attachment we're going to go ahead and use our Dynamic content here and the message ID will be the ID coming from our email there's our message ID and the attachment ID will be our attachment ID as well so if I just search for attachment we're going to use attachments attachments ID and the reason why we're using this one is because we want to make sure we pull in all of the different attachments whether or not I have one or seven or a thousand whatever it might be I want to get the ID for for each and every one of those and notice the moment that I click on attachments attachment ID we are going to get an applied to each or for each Loop here add it in with power automate in the cloud because we can have multiple attachments here that we are going to iterate over and count so that's kind of the purpose here now when we have this we're actually going to use this Loop to our advantage in order to count all the attachments because the way this applied to each will work is for each attachment we are going to apply the series of steps this logic to it well that means every attachment gets its very own Loop so if I come in here and want to count the loops that's going to let me know how many attachments I have so here to count the loops what we can use is another variable not initialized variable but this time use our variable for increment variable which will add a value to each Loop that we have here so we're going to go ahead and choose our attachment count variable and we're going to enter a value of 1 every time it Loops we want to count that attachment or count that Loop and essentially count from the attachments with it okay so that's our first step here so it allows us to be able to see all of the attachments that we have that we're bringing in in order to count them each time all right so I'm going to go ahead and test this flow save and test it to see if we can get that accurate count the this variable will tell us that accurate count and then afterwards why don't we just go ahead and add this to a SharePoint list just for some further verification so I've saved it I'm going to test it let's go all right so I'm gonna send myself an email here do this pretty quickly I'm going to have my subject filter which is YouTube test I'm going to make sure to include some attachments here and I'll just choose a couple different items that I have in here let me remove this one and let's see I'll include one more and a PDF here okay so we have these three we're just going to send it without any anything maybe just do a test here inside of the body that might just suffice and go ahead and send it and I've just received that email so I should be seeing the flow kick off any moments now and let's take a look what we're getting and here is our flow running we have our variable initialized we have our apply to each occurring so it's now currently looping and once this is complete we'll be able to see how many attachments we have for that email and already as the flow finishes up here I can open up our applied to each or for each Loop and we can see that we're showing one of three which means our increment variable should say three here at the end after you've gone over three loops and that's actually exactly what I have within that email that I've just sent out and there we have one two three attachments that's going to be exactly what I'm expecting there so that's allowing us to be able to count those attachments and now what we can do is if we want to add this to say a SharePoint list that I have here I can go ahead and then create an item each time we get a new email that will not only count the attachments but also store the attachments on that list so before we go ahead and apply to each here I'm going to go ahead and create an item in SharePoint so I'll do that first and then after we create the item we're going to go ahead and add our attachments to that item and also update that with the count so I'll go ahead and pull into my lists here we'll go ahead and and add in those fields so our name here we'll go ahead and say this is the from the subject I'll put my subject and the attachment counts I'm not going to add just yet because we haven't actually counted them here so what we could do is we could actually um say that we want to just create the item and then when we Loop through we can add each attachment to that item if we want as well so I'm going to add the create item first I'm just going to do a little bit extra steps here and then within our applied to each this is where we can come in here and choose to add our attachment to that item that we've created already so add attachment and then we can point to our SharePoint site and list once again and I'll do that here I'm going to use the ID of the item that I've already created we're going to then add in the file name and file content from the get attachment site get attachment action here so we'll go here and we'll come down and scroll for our Dynamic content for the name of the attachment the file content will be content bytes so we can get the actual content here there we go that's going to give us the exact info we want and then finally what we want to do is update this item that we've created in SharePoint with the uh the count of our attachments using our variable so then outside of the loop we can come here new step and do update item which will allow us to then take that same item that we've created and add an attachment to to add in the count there as well what we want to do is use this outside of the loop so then it doesn't actually rewrite to that SharePoint item every single time the loop happens we just get that total count after the fact so we'll come here and point to all of those again and as we've done here make sure I choose the right list there now we can go and find our attachments here's our ID there it goes and the only thing I want to update is the attachment count I do need to pass in the name again make sure it matches there and that is exactly what we want to have so now if I go ahead and save this and run it once again I'm going to use the previous run to test I'm going to make sure that it does show up on our SharePoint list with three attachments as we saw in our just previous check there so let's go ahead and hit test and here comes our flow once again initializing the variable we've created the item already we're now looking through our Loop to add all the attachments to that item and count how many there are before we finally update that SharePoint item in order to see how many attachments that came in within that specific email that we are logging so we are expecting it to be done any second now again we should have three there they are our flow is run successful let's take a look at SharePoint and here it is I've now been able let me zoom in on that been able to capture okay who is it from here's my subject there's the attachment count now if I select the specific item you can see that we have all of the attachments here and I have all the data that I want to be able to work with so if I select one I'm actually going to be able to physically see that there's our bootcamp that I have here that we work with pragmatic works you can see all those attachments and be able to view edit download everything you want from there so here working with power automate we're able to be able to look at all the emails that we are receiving through Office 365 Outlook count those email attachments utilizing initialized variable and increment variable and a loop and then finally in the end result here just to have some verification some logging and storage write that all into a SharePoint list now we have a place to store those attachments for each email if I wanted to put that in a document library and either SharePoint to OneDrive I could have done the exact same thing just by adding these attachments but now because it is a list item I can have the attachment count in there as well thanks for joining me here once again in YouTube please make sure to stay tuned for future videos don't forget to drop a like and a comment down below if you have any questions and stay tuned as we from pragmatic Works continue to populate more content here on YouTube for you and helping you out with everything Microsoft foreign yeah
Info
Channel: Pragmatic Works
Views: 2,027
Rating: undefined out of 5
Keywords: tutorials, how to, power automate, powerautomate, microsoft flow, flow, microsoft flo, microsoft flow tutorial, save attachments, control, flow based on condition, save attachments to sharepoint, save files to onedrive, powerapps tutorial, power platform, power automate microsoft, microsoft 365, office 365, office 365 email, count, count emails, count email attachments, variable, initialize variable, increment variable, loop, sharepoint, Jonathon Silva, Pragmatic Works
Id: ckwLETFcdRU
Channel Id: undefined
Length: 12min 16sec (736 seconds)
Published: Wed May 10 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.