Skip to main content

Notifications

Community site session details

Community site session details

Session Id : OF/hSeB1GQrCnDPZx/1k5y
Power Automate - Building Flows
Answered

Extract URL from Email body and download file

Like (1) ShareShare
ReportReport
Posted on 26 Dec 2023 15:23:29 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.

  • Laura_2021 Profile Picture
    27 on 31 Mar 2025 at 12:52:09
    Extract URL from Email body and download file
    Hi  there!
     
    Please kindly share the full flow path, step by step? I'm struggling to configure correctly. 
     
    This would only work on a predefined URL path, is that correct? I.E if the title of a report were to changed from 2024 to 2025, would this extraction still work automatically? 
     
    This function would be very helpful for a task, if I could get it to work :)
     
    Also struggling to understand the "compose - URI output" - it keeps bouncing back an error
     
    Thanks!
  • trice602 Profile Picture
    13,768 Super User 2025 Season 1 on 26 Dec 2023 at 20:53:31
    Re: Extract URL from Email body and download file

    Hi @mohuddle ,

     

    Nice!  Yeah it was a great experience for me too.  What I have used in the past, for unique file names is to use something like:

     

    formatDateTime(utcNow(),'yyyy-MM-dd')-rand(1000,2000).pdf which will give you a file name like:

     

    2023-12-26-1234.pdf (so date and random number)

     

     

  • mohuddle Profile Picture
    73 on 26 Dec 2023 at 20:48:51
    Re: Extract URL from Email body and download file

    Great exercise for me to go through all that. Much appreciated. I'm working on parsing the URL for a filename. Will post new thread for help on parsing the URL and turning into filename after I try some myself.

  • trice602 Profile Picture
    13,768 Super User 2025 Season 1 on 26 Dec 2023 at 20:38:30
    Re: Extract URL from Email body and download file

    Hi @mohuddle,

     

    Nice!  I am glad we figured it out together and I learned a lot too!  Now for the important part:  please mark one or more of my replies as a solution to help others find this walkthrough too!

     

     

  • mohuddle Profile Picture
    73 on 26 Dec 2023 at 20:31:00
    Re: Extract URL from Email body and download file

    Success!!

    mohuddle_0-1703622592628.png

     

  • trice602 Profile Picture
    13,768 Super User 2025 Season 1 on 26 Dec 2023 at 20:23:12
    Re: Extract URL from Email body and download file

    Results:

     

    trice602_1-1703622182314.png

     

  • Verified answer
    trice602 Profile Picture
    13,768 Super User 2025 Season 1 on 26 Dec 2023 at 20:20:28
    Re: Extract URL from Email body and download file

    Hi @mohuddle ,

     

    Ok, I figured it out and did a test for you.  The destination file path needs to contain the file name.pdf in the path and I was wrong about the format:  it's not the URL, it is the folder path, shown below.

     

    Here in this example, I downloaded (and then uploaded to OneDrive) successfully!!!  I recommend you get the flow working first and then you can work on the dynamic file name part (just name it something to test, like test.pdf).

     

    trice602_0-1703621954513.png

     

     

  • mohuddle Profile Picture
    73 on 26 Dec 2023 at 19:54:00
    Re: Extract URL from Email body and download file

    Copy/pasted it all to text editor, screenshot attached. FWIW, if i copy/paste my Destination File Path into a new browser tab, it opens right to the Project Notebooks folder.

    mohuddle_0-1703620409136.png

     

  • trice602 Profile Picture
    13,768 Super User 2025 Season 1 on 26 Dec 2023 at 19:38:35
    Re: Extract URL from Email body and download file

    Hi @mohuddle ,

     

    Yes!  Getting close!  What is the last part of the destination file path?  Need to make sure it is correct.  I believe the download URL is correctly formatted.

     

     

  • mohuddle Profile Picture
    73 on 26 Dec 2023 at 19:17:35
    Re: Extract URL from Email body and download file

    Looks like the last few attempts to test (when I said it was spinning) it wasn't seeing a "new" email any longer, so I just sent a another and it ran (but failed). Looks like I'm now grabbing the PDF URL ( [6] ) yay! and it is getting pulled in, but it seems to be hanging up on my OneDrive (if I'm reading this right). The connection is there in Power Apps. Do I need to put destination path in " "? Is there a way to find the path it's expecting and copy/paste?

     

    mohuddle_0-1703618184960.png

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard