cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sudosaurus
Post Partisan
Post Partisan

Send custom email with custom attachments in document library

Hello,

 

I have been requested to create a manual flow with the following requirements.

 

  • Send custom personalised email 
  • Attach PDF document from sharepoint document library to personalised email

The PDF document will be FirstName.LastName.PDF so the flow should match the user its sending the email to with the PDF document in the document library and send that file.

I have no problem with creating the custom email however I am not sure how to attach the PDF as per the above requirement?

The team sending these emails would like to send these off in batches of 200-300 users at a time so need to be able to make sure the flows are not re-run against the same users once they have been run once.

 

Can anyone help me with this?

6 REPLIES 6
StefanR
Advocate IV
Advocate IV

Hi @sudosaurus 

 

It's very easy to get the file content if you use the action Get file Content With Path.

I have assemble the path to the document in a variable documentPath which i use as input for the File path-Property.

.

This action generates a file content as output which you now can use as file content for the attachment property of the Send Mail Action.

SendAttachment.png

 

I have just pictured the problem of sending the atachments.

 

Right before that you should get all email-adresses where a field like  "Attachments were send" is set to false. Maybe you will have such a field.

After sending your mail you flag to true to be sure it will not send again.

 

If this reply has solved your problem, please mark it as solution.

 

Best regards

Stefan

 

So, I have set it as below however there needs to be some logic where it looks at the document library and picks the file name based on the name of the user the email is going to rather than specifying the filename in the Initialize variable section.

 

 

flow.png

Hi,

 

The path in the variable should be siterelative like that:  /DocumentLibraryName/Folder/Folder/File.pdf

 

If you configure the Get file content using path-Action you have to click in the FilePath-Property and select the formerly created variable from the dynamic section like here:

 

SendAttachment2.png

Hope it helps 🙂

 

Bye

Stefan

 

I dont understand why you're specifying a filename as this flow will be picking different files per user ie.

 

Chris Smith -> Chris.Smith.PDF
Bob Jones -> Bob.Jones.PDF
Sarah Smythe -> Sarah.Smythe.PDF

 

All these different named PDF files will exist in the document library - so we dont want to send the same PDF to every single person - each person will have their own unique PDF file.

Hi @sudosaurus,

Its just to demonstrate how you can come to a solution. It wasn't my intention to develop a fully functional process.

You are free to define a dynamic filename based on incoming data.

Now it's on you to make the finishing move 😉

If you have any further questions, please feel free to contact me.

Have a good night
Stefan

So my flow is now working like this but I do have a pending issue that Im hoping someone will have an answer to.

Flow details:

> file is added to sharepoint document library

> flow looks at the file ID and copies this to a 'person' field which I have named "Email Address"

> flow then gets the properties of the file that was added to sharepoint
> an email is created attaching the file added to the document library and sent it to the person that is specified in "Email Address" field

In this example, the file name is Chris Cundy.PDF

My HR department want to send out new contracts to staff using this method however they wish to include the employee number in the file name.
If the filename was instead Chris Cundy 123456789.PDF is it possible to me to only copy out the "Chris Cundy" from the file name and input this into the Email address field? So that then the attachment can still be sent with the email with the employee number in the file name?

 

email-flow.png

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (3,038)