cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AndyFRT
Level: Powered On

Sending a bespoke email with related PDF files

Hello there,

 

I'm facing a current issue on my Flow building.

 

I got a raw grid of data under Excel representing my customer agencies. I want to send each of their agencies + 2 of their responsibles in CC a message to inform them they will receive our new product.

 

My point is that I need to attach one or two PDF files to the mail (PDF files already loaded in Sharepoint) and that the PDF are specific to each agency (their naming is related to the Excel line number).

 

I already asked Flow to write an email for each line of the Excel but I can't link the PDF file that are stored in a document library to the Excel lines that are in this same library.

 

Any tips on how to do it?


Regards,

 

 

5 REPLIES 5
Community Support Team
Community Support Team

Re: Sending a bespoke email with related PDF files

Hi @AndyFRT ,

 

First, we need to define the table in the Excel file to get the data in the Excel file.

In addition, MS Flow is currently unable to obtain the Excel line number, and only the defined field values can be obtained, so you may need to establish a relationship between other defined fields and PDF files in order to obtain the specified file.

 

For example, create an ID field in an Excel table, it is directly equal to the item Id of the file in the Library.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AndyFRT
Level: Powered On

Re: Sending a bespoke email with related PDF files

Hi @v-bacao-msft 

 

Thanks a lot for your feedback.

 

I already defined the data as a table like below:

Example:

 

RefInformationTo:CC1CC2
1Address 1john@doe.comresp@doe.comresp2@doe.com
2Address 2jane@doe.comresp@doe.comresp2@doe.com
3Address 3jim@doe.comresp2@doe.comresp4@doe.com

 

I added a column called "Reference" labeling all my lines from 1 to the end (318 rows fyi).

 

My PDF files are named as Product_001.pdf to Product_318.pdf

 

I wanna automatize the emailing to the contacts with the related responsible in CC and attach the PDF files related to the reference. My point is that I'm not sure which Actions + Connections I should use (like Excel: For a selected row etc).


Regards,

Community Support Team
Community Support Team

Re: Sending a bespoke email with related PDF files

Hi @AndyFRT ,

 

Please refer to the following method to configure Flow.

 

  • Use List rows present in a table action to get all the rows.
  • Iterate through all the rows and configure Get files action to get all the files in the Library that store the PDF files.
  • Use Condition to determine if the file number is equal to Ref in the current rows.
  • Use split() function to get the numbers in the file, use int() function to turn the results on both sides into numbers, and see if they are equal. Because your file number has a number like 001, so we need to use int() function when comparing.

 

Image reference:

17.PNG

18.PNG

 

There may be errors when Flow is executed. You can ignore it because the PDF file is not placed in a separate library, so other files or folders will be traversed, an error will occur, but does not affect the acquisition of PDF files.

 

Please take a try.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AndyFRT
Level: Powered On

Re: Sending a bespoke email with related PDF files

Hi @v-bacao-msft 

 

I just tried your layout using PDF files named from 001 to 007 and a simplified Excel grid so the int(item()['{Name}']) should work.

Test.JPG

 

I tried to run the flow but I'm sent back to the following error message. It seems to mean the string 001 isn't converted into an int number (FYI, other my first int expression is as follow 

int(items('apply_to_each')['Ref BAT'])

Test2.JPG

 

Do you have a clue on why it isn't considered as an int?


Regards,

Community Support Team
Community Support Team

Re: Sending a bespoke email with related PDF files

Hi @AndyFRT ,

 

You could add two Compose actions above Condition, enter the two Expressions you are currently using, and see which Expression has an error.

I am currently speculating about possible errors as below:

 

First, int(items('apply_to_each')['Ref BAT']) needs to be changed to int(items('Apply_to_each')['Ref BAT'])

And if Ref BAT is used correctly, you could check Body of List rows present in a table to see how this field is displayed in Body.

 

Second, you could check whether the field value of Dynamic content output of Name contains the extension. You can view the value of this field in Body of Get files action.

 

Third, I mentioned in the previous Post that there may be errors, because Get files action will get all the files and folders, so there may be such an error.

You can check if there are any successful results in Apply to each 2, or you can check if the email address used for testing has received the expected email.

If so, this Flow has achieved the expected requirements, and these errors are negligible.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 228 members 5,227 guests
Please welcome our newest community members: