web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Sending a bespoke emai...
Power Automate
Unanswered

Sending a bespoke email with related PDF files

(0) ShareShare
ReportReport
Posted on by 5

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,

 

 

Categories:
I have the same question (0)
  • v-bacao-msft Profile Picture
    on at

    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,

  • AndyFRT Profile Picture
    5 on at

    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,

  • v-bacao-msft Profile Picture
    on at

    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,

  • AndyFRT Profile Picture
    5 on at

    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,

  • v-bacao-msft Profile Picture
    on at

    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,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard