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

When a sharepoint file is created, attach the file to an email and send it to a specific person with a specific email subject

Hello,

 

New power user here. I have only made one other flow and it was much simpler than this is proving to be.

 

I am trying to create a flow so that when a file is uploaded to the "Client Invoices" folder, the file that was uploaded is attached to an email and sent to a specific client. The names of the files that are being saved to the "Client Invoices" folder are autogenerated from QuickBooks and they look like this "QBSE_RBI_Solar_Inc_Invoice_601.pdf", or "QBSE_RBI_Structures_Invoice_706.pdf". So, if the file name has "Solar" it needs to go to person1@email.com and if it has "Structures" it needs to go to person2@email.com. The email subject needs to be "LeanGo Invoice ### PDF Copy" The numbers are listed in the title of the file as well.

 

I saw another post that I was following and trying to copy but it's not exactly what I need and they use a "LineBreak" which when I searched for it didn't exist.

 

They achieved their result using a SharePoint list so I went ahead and created a list and here is what it looks like.

 

I also want to make this flow so I can easily edit this as we add new clients. I am stumped by this flow and would really appreciate any and all help or to learn if my idea is even possible (I think it is). Also sorry for not embedding the image, it kept giving me errors.

 

Thanks in advance,

Zack

5 REPLIES 5
annajhaveri
Super User
Super User

@zbishh2  you need to create a flow which uses "When a file is created (properties only)" trigger, select the sharepoint site, library and folder in the trigger parameters.

 

Then add Get Items actions to get items from Clients list. Then add filter array action to determine which File Tag from the list matches with the current file name, configure the filter array action as below

 

annajhaveri_0-1617348687581.png

 

 

In the From parameter select value (List of items) from Dynamic Content -> Get Items

Then use below expressions from  Dynamic content -> Expression

toLower(triggerOutputs()?['body/{Name}'])

right side use below expression from  Dynamic content -> Expression

toLower(item()?['Title'])

 

Then you can add compose action and configure below expression to get Email Recipients

 

 

 

body('Filter_array')?[0]?['EmailRecipients']

 

 

 

To attach the file to Email do following

1. Add "Get file content using path" action and configure it as per below screenshot

2. Add Send email action and in attachments section, select file name (from trigger) for attachments name parameter and select File Content (from get file content) for attachments content parameter, as shown in below screenshot

annajhaveri_1-1617348882807.png

 

 

Then add Send Email action and use output of compose action in the To parameter.

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

I tried your flow all the way through and I am getting an error at the compose step. 

zbishh2_0-1617298380220.png

Everything above this is configured as you said. Here is the configuration of the compose step that is failing.

zbishh2_1-1617298505556.png

 

 

@zbishh2  sorry i think the instructions i gave in the last response were a little messed up as i had not actually tested those steps, so i updated the instructions, you need to change the trigger and filter array action and compose action expressions, so please read my previous response again and configure your flow accordingly.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

When I try to do the step after compose, which is "Get file content using path" it switches the action to "apply to each" and puts get file content using path inside of apply to each as shown in this screenshot.

zbishh2_0-1617391001914.png

However,

 

I found a work around by creating a folder for each client and doing a simple

"When a file is created in a folder"->

"Get File Content" ->

"Send an email"

 

I think using your solution would still be better as it would set me up for less upkeep work in the future. It is up to you if you want to continue to try to solve this for me. 

 

Thank you so much for you help. This was a very warm welcome since this was my first post on the community board. Looking forward to learning more about the power platform.

 

Best,

Zack

@zbishh2  from your screenshot it looks like you are using the path from the Dynamic Content - Get Items property, but you need to select the Full Path from Dynamic Content -> Trigger property

 

You need to use the full path as highlighted in below screenshot

annajhaveri_0-1617603303638.png

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,021)