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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create dynamic variabl...
Power Automate
Answered

Create dynamic variable as attachment to send as e-mail message with Outlook (dynamic file name)

(0) ShareShare
ReportReport
Posted on by 6

I'm trying to attach a file in an Outlook email instance that has been downloaded and saved to my files generated from the first part of this same flow. I don't know how to add this file as an attachment. I've tried creating a variable since the file name will change each time this flow is run. The file path part is the location and name of the file I'm trying to attach to the Outlook email.

 

pmontray_1-1703874241842.png

I set my variable to 'RootPath' - is that right for what I'm trying to do?

pmontray_3-1703874609798.png

 

Using 'Send email message through Outlook':

 

pmontray_2-1703874539482.png

 

I've run my flow, and it will send the e-mail but no attachment. 

 

I also thought about setting the clipboard text as the path+name of the file, but I can't figure out how to make that as an attachment in the Outlook instance. I get an error saying it must be 'list of files' or no error at all, just no attachment gets sent.

 

I plan on running this weekly, so what's the best way to attach files on the outlook email message? Ideally it attaches the most recent file that has been added to a specific folder.

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    You should simply put the entire path of the file that you have now used in Get file path part as the variable. You don't need a part of the path. You need the entire path. So, use Set variable to set the entire path to a variable value. Then use that variable as the attachment.

         -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

     

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    You can view what %RootPath% is in the variable pane after running up to this point. 

    I think instead of get file path part, you just want to put the entire filepath you have in that first screenshot into the attachment, that should be good as a file. Except it’s missing an extension, so I would add the proper extension. 

    if that doesn’t work, then get files, put in the folder and the proper filter, advanced sort by last modified descending, then the top file can be referenced by %Files[0]%.

     

    good luck!

  • pmontray Profile Picture
    6 on at

    The get files, advanced sort by last modified and descending worked!

     

    Thank you so much. I used that and set variable to %Files[0]% and then as the variable in attachments I used %NewVar% and boom I received the e-mail with the latest attachment.

     

    The only thing I need to figure out now is how to close the file (in this case it's excel) that is generated from the earlier steps in the same flow before the e-mail gets sent....

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 796

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 538

Last 30 days Overall leaderboard