Send Email with Multiple Attachments from SharePoint Library Docs

Introduction

In this article, we will explore the process of sending an email with attachments using Power Automate, specifically focusing on scenarios where files with their metadata are created in a SharePoint Library, such as project documents.

Let’s assume we have a SharePoint Document library with some project files uploaded. Follow the steps below if you want to filter the project’s documents from the SharePoint library and send those files as attachments through email.

Project documents

To create a flow, log in to Power Automate, then click on the Create icon in the navigation bar, and select Instant Cloud Flow.

Now provide a flow name, then select the trigger “Manually trigger a flow” to run the flow.

Manually trigger a flow

Click on the next step, then select "Initialize variable" to create a variable. Provide the name of the variable as “varAttachments” and type it as Array. This array variable will be used to create an array of all documents.

Initialize variable

Click on the next step, then select the "Get files (properties only)" action. Provide the SharePoint site address, and library name, and add the below query to get particular documents from the library: ProjectName eq 'Project A'

Get file properties

Click on the next step, then select the "Get file content" action to read all the file contents. Provide the site address, list name, and ID from the dynamic content.

In the File identifier, add the identifier of getting files from the dynamic content. After setting the file identifier, an "Apply to each" loop will be added automatically to get the file content of each file. Set “Infer Content-Type” as No.

Apply to eacy

Click on the next step then select Append to array variable action inside the apply to each loop to create an array. Now select the variable “varAttachments” as the name, which we have created in Step 3. Then set the value with the below JSON

  • Name: Set the file name with an extension from the dynamic content.
  • ContentBytes: Set the body of the Get file content from the dynamic content.

Apply to each

Send attachment via email

  1. To send an email, click on "Add an action" and select "Send an Email V2 Outlook".

  2. Provide the recipient's email.

  3. Set the Subject and Body of the Email. Then click on the "Show Advanced" option.

  4. In the attachment section, click on the icon to switch to the entire array of attachments.

  5. Then set the value of attachment to the "varAttachment" variable. Also, you can set the importance from low to high.
    Send an email

Once your flow is ready, click on "Save" and test the flow.

Below is the email output screenshot:

Project documents

Conclusion

By following these steps, you can efficiently automate the process of sending emails with multiple attachments from a SharePoint library using Power Automate. This streamlined approach enhances productivity and reduces manual effort. Enjoy learning and exploring the capabilities of Power Automate!


Similar Articles