Power Automate - Send SharePoint files as attachments
Artigo
Observação
This is an open-source article with the community providing support for it. For official Microsoft content, see Microsoft 365 documentation.
Scenario
We have a library with a number of folders, and each of the folders contains multiple files. These files need to be sent out as attachments, when needed. There are many use cases for this capability, but the example in this article is related to contract management. As you might have guessed, these documents need to be sent as attachments outside of the company.
What do you need
Power Automate, standard M365 license
SharePoint library - this could of course be a Teams connected library
In our SharePoint team site we have a Contracts folder and inside this folder we have our partners and customers as sub-folders.
The contract files are located inside the customer/partner folder as below
Using the library menu | click Automate | Power Automate | Create a flow
The flow we are building is an Instant Flow, so in the dialog click "See your flows" to navigate to the Flow editor page.
Choose to create a new flow | Instant-from blank.
Name your flow, choose to "For a selected file" as trigger, and then click Create.
Whenever the flow runs we need some data from the end user. In this case "Recipient Name" and "Recipient Email". We will create two variables:
Recipient Name
Recipient Email
FolderName | this is the folder we will grab the files from
AttachmentsArray | this is the array where we will put all files to be sent
The next step is to grab the data for the item that started the flow. That way we can verify if the "item" that started the workflow is a file or a folder.
If folder is "true", we will then append the folder name to our variable "FolderName", and use this in the next action to grab all the files properties in the current folder.
We will then use "Apply to each" to append the files' content to our Attachment array variable. The trick here is to append the right content. Thanks to this guide at the Flow forums by Sunay Vaishnav, I finally managed to get this working.
As of this writing, the best way to append SharePoint files to an attachment array is:
A fonte deste conteúdo pode ser encontrada no GitHub, onde você também pode criar e revisar problemas e solicitações de pull. Para obter mais informações, confira o nosso guia para colaboradores.
Comentários do Microsoft 365 community content
O Microsoft 365 community content é um projeto código aberto. Selecione um link para fornecer comentários:
O email continua a ser o método de comunicação principal e preferencial para muitas empresas. Em algumas situações, os emails também são recebidos como formas eletrônicas oficiais de aprovação. Este módulo fornecerá uma lista das práticas recomendadas que você pode seguir ao usar o Microsoft Power Automate para emails de entrada e saída.