How to Send SharePoint List Attachments 📎 via Email with Power Automate

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I have the SharePoint list to track invoices the invoice has been added as an attachment to each item that doesn't have a pending status this Microsoft power automate flow runs every weekday morning at 8:00 a.m. looking for any items in this list marked as ready to send in this Microsoft power automate tutorial I'll cover how to build a flow that will send an email for each item marked as ready to send this flow will also indicate the date and time the invo was sent out the logic in this flow can be applied to many different scenarios make sure you stick around till the end of the video video where I'll show you how to combine multiple attachments into a single email to get started you'll need a SharePoint list with attachments if you'd like your flow to bulk send items you will need a column in your SharePoint list to Mark which items need to be sent even if you plan to trigger your flow manually by selecting an item it's good practice to Mark items that have already been sent currently my SharePoint list items only have a single attachment at the end of the video I'll cover how to handle multiple attachments in power automate create a new instant Cloud flow give your flow a name and select the manual trigger we'll start off by creating a manually triggered flow once the flow is ready to go we'll replace the manual trigger with the recurrence trigger I'll be running my flow once a day at the time of filming this there isn't a way to select a default designer and Microsoft power automate defaults to the new designer you'll need to switch to the classic designer to follow along add a get items action select your site address and list name click on show Advanced options add a filter query always ensure you are using the internal column name in my case it's status with a capital S I'll use EQ for the equals to operator I only want this flow to run for items that are marked ready to send I'll insert that text between single quotes anytime I use a filter query in a get items action I always add a compose action to store the number of items returned insert and expression use the length function and insert the value Dynamic content from the get items action run a test I'll filter out my list by items that are marked ready to send if you have a large list display the total count for any of your columns I've got five items that are marked ready to send I'll compare this number with the number in my compose action if the number in your compose action isn't returning the correct number there can be a few reasons for this either your filter query isn't correct or you have more than 100 items in your SharePoint list if that's the case you'll need to turn on pagination and set a threshold I only have 30 items in my list so I will leave pagination off if you have a large list of SharePoint items it's a good idea to set a top count the top count will limit the number of items returned which will speed up your flow runs this is especially helpful when building and testing your flow I'll set the top count to three and run a test since this flow uses the get items action will want to ensure that the item has attachments before running the get attachments action typically you might add an apply to each and condition action to Loop through all items returned to check for attachments however if the get items action returns a lot of items doing it this way is inefficient as the apply to each action will need to Loop through each item to run a check instead we'll use a filter array action to filter out only items that have attachments first before we Loop through them this will improve the efficiency of your flow especially if you have a lot of items to learn more about how you can use a filter rate action in your flow check out this tutorial add a filter array action to your flow remember to rename your actions to keep your flow organized in the from field insert the value Dynamic content from the get items action in the first value field insert the has attachments Dynamic content from the get items action we'll leave the operator as is equal to in the second value field enter true in lowercase add a compose action to store the number of items returned from the filter reaction I'll use the length function and insert the body outputs from the filter array action I'll remove attachments for two of these items in my get attachments action I'm going to remove the top count since I'm working with a small number of items let's run a test the get items action has returned five items and the filter array action has filtered out the items that have attachments I'll add a scope action to the top of my flow and drag all four of these actions into it I like using scope actions in my flows to quickly collapse multiple actions they also help me to keep my flow organized now that the items with attachments have been filtered out we use and apply to each action to Loop through those items insert the body Dynamic content from the filter array action this next step is optional however when I use filter array actions in my flows I like to use compose actions to store the dynamic content the get attachments action requires an item id unfortunately when you use a filter array action in your flow the only Dynamic content available from that action is item and body we'll need to use an expression to return the dynamic content from the filter array action insert the item function a question mark square brackets and single quotes in between the single quotes insert the dynamic content key which is ID in this case the dynamic content keys can be found in the output of the filter array action the keys are the text in red between double quotes they are also case sensitive add a get attachments action select your site and list name in the ID field insert the outputs from the compos action above alternatively you can insert the expression directly into this field I'll add a compose action to return the attachments display name power automate has automatically nested the compose action inside of an imply to each action this is because the get attachments action will always return an array of items for this particular example there will only be a single attachment for each SharePoint item the apply to each action isn't necessary in this case and we can make the flow more efficient by avoiding it an array is a collection of items the first item in an array is zero second is 1 third is two and so on to return the display name of the attachment without the apply to each action we'll need to use an expression in the compose action click on the three dots and select Peak code select the content key which is the text between the single quotes by double clicking it copy it to your clipboard delete the dynamic content and pull the compose action outside of the apply to each action delete the apply to each action add an expression enter a question mark square brackets and a zero press the down arrow key to go to the end of the expression and enter another set of square brackets and single quotes paste the dynamic content key press the up Arrow key to go to the start of the expression click on the dynamic content Tab and insert the body Dynamic content from the get attachments action this expression will take the first item which is indicated by the item key the zero between square brackets and return the display name add another compose action copy this expression and replace display name with ID make sure you use a capital I run a test insert a get file content action we'll use this action to get the content of the attachment select the site address in the file identifier field insert the outputs from the compose action above add a send an email V2 action to your flow whenever I use a send an email V2 action in my flows I always insert my email into the recipient field while I'm building and testing the flow once I've confirmed the format of the email I'll replace my email address with the appropriate recipient or recipients I'd like to insert Dynamic content into the subject line and body of my email because we've used a filter array action above and the apply to each action is looping through those items you cannot use any of the dynamic content from the get items action if you do this will happen which isn't what you want this is because We're looping through the output from the filter array action and not the get items action instead you'll need to use the item expression as we've done above here to compose the dynamic content power automate has converted the expression label to this when I click on this Dynamic content label the expression doesn't appear click on the three dots of the compose action and select Peak code copy the expression to your clipboard add a compose action for each Dynamic content you'd like to return from the filter array action remember to view the outp puts of the filter reaction to get the dynamic content keys I'm going to grab the invoice number amount and date the invoice number is stored in the title field I'll add a dollar sign right before the dynamic content for the invoice amount I'd like to format the invoice due date to do that I'll wrap this entire expression in a format date time function place your cursor inside the closing bracket add a comma in single quotes in between the single quotes enter a date format I'll use this format I'm going to delete this action so that I can run a test and view the outputs of the compos actions above there are quite a few actions nested here I'm going to add a couple of scope actions to reduce the amount of space these actions are taking up that looks a lot better I've added back the send an email V2 action I'll insert the dynamic content from above into the subject and body of the email click on show Advanced options in the attachments name field insert the outputs from the compose action that is storing the attachment display name which is essentially the file name including the extension in the attachments content field insert the file content from the get file content action run a test let's check to make sure the attachment opens without any issue if your flow for sending multiple attachments looks like this it's wrong the issue with this flow is the second apply to each action take a look at what it's looping through this apply to each action is looping through each attachment because the send an email action is inside the apply to each Loop if a SharePoint item has more than one attachment it would send a separate email for each attachment to send a single email with all attachments we'll need to collect the attachments first then send the email outside of the apply to each Act action first we'll need to initialize an array variable in the root of the flow after the get file content action add an append to array variable action I'm going to copy the array structure from the send an email action click on the three dots of the send an email V2 action and select Peak code scroll down to the attachments the attachment array is here highlight the content between the square brackets and copy it to your clipboard in the append to array variable paste the content from your clipboard highlight the text between the double quotes here and replace it with the display name Dynamic content from the get items action do the same for the content bytes and replace it with the file content from the action above next delete the dynamic content from these fields click on this icon to switch the input to entire array insert the variable here pull the send an email action outside of the apply to each Loop because we're using an append to array variable action we'll need to clear the variable after the email has been sent otherwise each time this applied to each action Loops through it'll continue to append attachments to this variable which isn't what we want add a set variable action insert the null function now the flow will first Loop through each SharePoint item collect the attachments for the current item into this variable and send a single email with all attachments then set the variable to null these two compos actions are not necessary in this flow they can be deleted in my SharePoint list I'm going to add multiple attachments to a few items run a test after an email has been sent out I want to change a status from ready to send to sent for payment and include a timestamp for when the invoice was sent out add an update item action after the set variable action in your flow select your site address and list name for the ID field insert the outputs from the compose action that is storing the item id select a status from the status dropdown for the timestamp insert the UTC Now function run a test in my SharePoint list the client column is a lookup column the client email address column is displaying the corresponding email address or addresses for the client because my email addresses are separated by a semicolon I can simply insert the client email address Dynamic content into the recipient field remember that because we're using a filter array action to Loop through the items returned we'll need to use an expression to get the client email address from the filter array action compose an expression as we've done previously by copying the dynamic content key from this action and insert it into an expression in the send an email V2 action delete the dynamic dnamic content label in the recipient field and pull the action outside of the apply to each action this apply to each action isn't necessary and can be deleted insert the outputs from the compos action into the recipient field you can use a variety of triggers for a flow like this use a recurrence trigger if you'd like to run this flow on a schedule I've copied the original flow and I'll delete the manual trigger and replace it with the recurrence trigger change the frequency to week and the interval to one click on show Advanced options choose your time zone and select all the days you'd like your flow to run I'll select all the weekday ch choose a time you'd like your flow to run at this flow will now run every weekday morning at 8:00 a.m. you can also use the for a selected item trigger I've copied the original flow and I'll delete the manual trigger and replace it with the for a selected item trigger select the site address and list name I'm going to delete this entire scope action and insert a get item action select your site address and list name insert the ID Dynamic content from your flow trigger next insert the ID from the get items action into the get attachments action in the send an email V2 action I'll replace the dynamic content with the dynamic content from the get items action since the trigger of this flow will only return a single item the applied each action isn't necessary in this flow drag the these actions outside of the apply to each action delete the apply to each action save your flow and run a test from SharePoint in SharePoint I can select any item from the list even if it's already been sent and run the flow on the selected item lastly if you're using the get items action in your flow and you've limited the number of items returned with a top count ensure that you've removed this before running your flow What scenario would you use this flow for and how would you modify it to suit your needs let me know in the comments down below if you found this video helpful please consider giving it a like are you making these three mistakes when it comes to the apply to each action check out this video to find out if you are don't forget to subscribe so you don't miss out on any other power automate tutorials thanks for watching
Info
Channel: A Creative Opinion
Views: 6,482
Rating: undefined out of 5
Keywords:
Id: DCxwCALD7hk
Channel Id: undefined
Length: 20min 25sec (1225 seconds)
Published: Wed Nov 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.