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 / Extract URL from Email...
Power Automate
Answered

Extract URL from Email body and download file

(1) ShareShare
ReportReport
Posted on by 73

I would like to build a flow that monitors my Inbox and downloads a file linked in the body which is given as a URL. The "When email arrives (v3)" trigger is working. I'm getting hung up on how to build the appropriate function to look for a URL in the body of the email that contains the link to download a PDF file and save to my Documents folder.

 

The email has a link to a .txt file and another link for a .pdf file. I only need to download and save the .pdf file to my documents folder.

Categories:
I have the same question (0)
  • trice602 Profile Picture
    15,404 Super User 2025 Season 2 on at

    Hi @mohuddle ,

     

    Can you please paste in a sample email?  We should be able to parse out the pdf URL quickly here.

     

     

  • mohuddle Profile Picture
    73 on at

    I think the URLs I'm posting are getting removed, so I'll post a screenshot instead. These won't work, but the structure is the same. The email will contain a link to a .txt file and another to the .pdf file. I only need the PDF file.

  • mohuddle Profile Picture
    73 on at

    Here is what the body actually looks like.

  • trice602 Profile Picture
    15,404 Super User 2025 Season 2 on at

    Hi @mohuddle ,

     

    Here's some framework to help you get started.

     

    trice602_0-1703608689800.png

     

    Essentially I am splitting the body based on the the (return) to give me different parts of the body.

     

    split(outputs('Compose'),uriComponentToString('%0A'))
     
    So in my example, I have two lines in my body and I want the second one.  In my example, the first item is [0], the second is a blank line [1], and the last is [2].  Yours most likely will be different but play around with the output by splitting and determine which element that pdf url is in because the email template will be the same every time so once you get the correct item it will work every time.
     
    trice602_1-1703608822458.png

     

    So after splitting, I can select the 2nd item and now I have the url to download in my next action.

     

    trice602_2-1703608870922.png

     

     

  • mohuddle Profile Picture
    73 on at

    I tested the element with 3, 4 and 5. With [4] it only pulls in the .txt URL. With [3] and [5] it pulls in null/nothing. Inputs and Outputs are blank for Compose 3.

     

    Compose has the full body of a recent email copy/pasted into it.

     

    Compose 2 has--

    split(outputs('Compose'),uriComponentToString('%0A'))
     
    Compose 3 (when it's able to pull in the .txt link) has--
    outputs('Compose_2')[4]

    mohuddle_0-1703613076025.png

     

  • trice602 Profile Picture
    15,404 Super User 2025 Season 2 on at

    Hi @mohuddle ,

     

    The outputs from 3 and 5 should be blank.  If 4 is the .txt link, what is in [6]?

     

     

  • mohuddle Profile Picture
    73 on at

    Well...it's just spinning now. So maybe a good sign 😂 One thing I found odd was in the Upload File from URL step, the Destination box isn't "intelligent" like other components in Power Automate that ask for file path. When I click inside I don't get any pop-up or dialog to navigate a OneDrive path. It's fully manual. Not certain what it expects here so I just put / for the root of ... wherever. I'm guessing my OneDrive. Should it be a \ and not a / ??

  • trice602 Profile Picture
    15,404 Super User 2025 Season 2 on at

    Hi @mohuddle,

     

    Nice!  So next step that I would do is put the captured URL in a variable or compose and inspect the output.  You may need to encode the URL to process special characters.

     

    Also to determine the right format for the upload file action, try hard-coding to a folder so you see what it looks like, then you will know which slash to use, etc, etc.  But agree, I think you are close.

     

     

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

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard