cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jaysomrivera
Regular Visitor

Send all files as attachment by email from a Share Point Document Library Folder

Greetings

 

Have been trying this for a time now. 

 

I need to tell flows to get all the files in my selected SharePoint Library folder and add them as attachments to an email.

I tried Get File Items and it works but it would sent an email for each file withing the selected SharePoint Library folder. I need to send just one email with all the files as attachments found in the selected SharePoint Library Folder.

 

Any help would be greatly appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
v-yuazh-msft
Community Support
Community Support

Hi @jaysomrivera,

 

I have made a test on my side, please refer to screenshot below to create the flow:

Capture.PNG

 

Capture.PNG

 

The expression in the Condition as below:

@equals(items('Apply_to_each')?['{IsFolder}'], false)

The expression of ContentBytes as below:

body('Get_file_content')?['$Content']

The flow would run successfully as below:

Capture.PNG

 

The email would be sent with attachment as below:

Capture.PNG

You could also refer to link below to learn send an email with multiple attachments:

https://preview.flow.microsoft.com/en-us/blog/multiple-attachments-single-email/

 

Best regards,

Alice

View solution in original post

13 REPLIES 13
v-yuazh-msft
Community Support
Community Support

Hi @jaysomrivera,

 

I have made a test on my side, please refer to screenshot below to create the flow:

Capture.PNG

 

Capture.PNG

 

The expression in the Condition as below:

@equals(items('Apply_to_each')?['{IsFolder}'], false)

The expression of ContentBytes as below:

body('Get_file_content')?['$Content']

The flow would run successfully as below:

Capture.PNG

 

The email would be sent with attachment as below:

Capture.PNG

You could also refer to link below to learn send an email with multiple attachments:

https://preview.flow.microsoft.com/en-us/blog/multiple-attachments-single-email/

 

Best regards,

Alice

Hi, 

When I try to replicate this, I receive the error:

InvalidTemplate. Unable to process template language expressions in action 'Append_to_array_variable' inputs at line '1' and column '2015': 'The template language expression 'body('Get_file_content')?['$Content']' cannot be evaluated because property '$Content' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.

Is there any solution for this?

Best regards,

Ludwig

 Hi!

here it is the solution!

You have to modify 

body('Get_file_content')?['$Content']

to this:

"ContentBytes": "@{base64(body('Get_file_content'))}"
It is important to put body('Get_file_content') into base64 function.
2019-11-28_16-52-22.pngKépkivágás.PNG
 

 

Anonymous
Not applicable

Hi @v-yuazh-msft .

Thank you you very much for you solution, my flow someway is very similar to this one here but I followed all the steps and I just keep getting one email per attachment, is very confusing for me because I'm not getting any error running the flow. Very appreciatte if someone could help me with this

 

..

 

For me, its not working for attachments which are pdf files. I get the error 

susilacherla12_0-1607622480200.png

 

I rewrote the flow and with below it worked 

 

susilacherla12_0-1607693423744.png

 

Hi this looks like a great option, I managed to recreate the flow and it works sending the email with the attachcments (PDF files) but for some reason when i try to open the files it gives me an error message that it cannot open the file "because it is either not a supported file type or because the file has been damaged"

any thoughts on how to solve this please?

 

thank you

Yes, I faced a similar issue when I began.  Can you share your flow and I will compare with mine. You can hide the sensitive and confidential data

Thank you for getting back to me!

For some reason beyond my understanding (i am super new to this) i write it again and it worked! i must have missed something before.

I did another flow similar to it, but to send me the links instead of the files, and it also works, the problem is that it is sending all the links together (separated by comma) and i would like to have them all in separate rows and not a clue how to do that. Any thoughts

Screenshot - Link flow.png

@v-yuazh-msft ,
Thank you for your solution, I have been able to replicate this workflow 🙂


Regards

Claire

@AgainOpen ,
Did you get your issue resolved with the PDF Files 
when i try to open the files it gives me an error message that it cannot open the file "because it is either not a supported file type or because the file has been damaged"

I have the same issue, and was wondering how to fix it.
Thank you
Claire

Hi Claire.

I changed a couple of things and it worked OK for me.

I keept it all the same up to the "Conditions" - changes are as per images  

On the Get FIle content, the "Identifier" comes from "Get file (property only)" 

on the Append to Array type in the values

{ "Name": File name with Extension,

"ContentBytes": "File Contetnand File Content

}

File Name with Extension from Get file (property Only) and File Content form the Get file Content

the add the Send eamil and use the attachment section to add the "Apend to array variable" 

 

i just tested it again and it sends me all the PDFs correctly,

Hope it helps

ScreenSHot 1.pngScreenSHot 2.jpg

Thank you @AgainOpen 
That's how I've built it, but the issue I have is the attachment PDF files are blank 😕

Any idea's why this would happen as the files in the SharePoint library are not blank

Thank you
Claire



Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

AI Builder AMA June 7th carousel (up on May 25th, take down June 8th) (1).png

'Ask Microsoft Anything' about AI Builder!

The AI Builder team invite you to ask questions and provide helpful answers at our next AMA.

Users online (1,536)