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 / How to send emails and...
Power Automate
Unanswered

How to send emails and automatically fetch an attachment from a folder

(1) ShareShare
ReportReport
Posted on by 23

Hello, 

 

Would it be possible to Power Automate sending bulk emails and have it fetch a file attachment that is unique to that specific person? I have seen guides where the path to the file is predefined but I was wondering if I could tailor it to my case where the attachments are all in one folder but the file names are labeled with the person's unique identifier(employee ID). e.g. "103.pdf". I then have an excel file that lists all the employee IDs with their respective email address. If I could automate sending them out that would be really great. Currently been playing around with Power Automate but struggling with structuring the flow.

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

    Hi @judebot ,

    I made a template for your reference:

    vchengfenmsft_4-1676536287351.pngvchengfenmsft_5-1676536321306.png

     

    Recurrence: UTC+8 time zone, triggered at 8:00 am

    vchengfenmsft_0-1676535583305.png

    Define an array variable, if a user has multiple files, they can also be stored in an array to send mail

    Filter query : substringof('@{items('Apply_to_each')?['UserID']}',FileLeafRef)

    Filter out files with user IDs in their filenames

    vchengfenmsft_1-1676535613175.png

    Get the contents of the file, put it into an array

    vchengfenmsft_6-1676536428308.png

    send file array

    vchengfenmsft_3-1676535865830.png

    Here is result:

    vchengfenmsft_7-1676536562309.png

     

    Best Regards

    Cheng Feng

  • judebot Profile Picture
    23 on at

    Hi Cheng. This works perfectly. I can't thank you enough. I would have never gotten this to work on my own so kudos to you. I really appreciate your help. Thank you so much!

  • judebot Profile Picture
    23 on at

    Hi @v-chengfen-msft, Hope you could help me out again. So after testing, seems like other people are getting attachments that aren't theirs. So they're getting their attachments and then those of others as well. I have checked multiple times and I do think I have followed all the steps accurately. Any thoughts on what might be happening?

  • v-chengfen-msft Profile Picture
    on at

    Hi @judebot ,

    Could you show a screenshot of the flow you built?

     

     

    Best Regards

    Cheng Feng

  • judebot Profile Picture
    23 on at

    1.PNG2.PNG3.PNG4.PNG

  • v-chengfen-msft Profile Picture
    on at

    HI @judebot ,

    Judging from the screenshots you provided, there is no problem with the overall flow

     substringof:

    substringof('103',FileLeafRef) will filter out all files containing '103' in the file name, if a file name is 2103.xlsx will also be filtered out.

    Could you tell me if the same part will appear for the employee id or if a certain employee id is a part of another employee id?

     

    Here is a link about filter query for your reference:

    Power Automate SharePoint Get Items Filter Query + 12 Examples - EnjoySharePoint

     

    Best Regards

    Cheng Feng

  • judebot Profile Picture
    23 on at

    Hi @v-chengfen-msft , 

    I can confirm that employee IDs are unique non-repeating 7 digit figures. Sending also the screenshot from my excel file with the ID and email.

    5.PNG

  • Verified answer
    VictorIvanidze Profile Picture
    13,073 on at

    Before "apply to each 2"  set "Set variable" action for variable Test. Value should be [].

  • judebot Profile Picture
    23 on at

    Hi @VictorIvanidze 

     

    This worked like a charm. Thank you so much! You're the man!

  • judebot Profile Picture
    23 on at

    Hi again @v-chengfen-msft @VictorIvanidze, this has been working perfectly for me and I can't thank you enough. I was just wondering if I could turn this into a Power App and what changes would I have to make? Turns out, a lot of people need a tool just like this and making a more app styled interface would help.  

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard