cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lliu_western
Resolver II
Resolver II

Automatically download a file that is in an url link inside the e-mail

Hi Community,

 

I need to automate a process. Below is the story what I need to automate.

 

When an email is received, inside the e-mail, it contains a "Download" button. I need the automate the process where when the e-mail is received, it automatically download the file within the e-mail by clicking the "Download" button that connects to an url and save the downloaded file in a particular folder.

 

Any resources/documentation on how to achieve this either through Power Automate or Power Automate Desktop will be great, thank you. 

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

No tips, just the expression:

substring
(
  substring(outputs('html'), indexOf(outputs('html'), 'https://api')), 
  0,
  indexOf(substring(outputs('html'), indexOf(outputs('html'), 'https://api')), '"')
)

linkIRL.png

Result:

linkURL-Result.png

View solution in original post

10 REPLIES 10
Paulie78
Super User
Super User

Quite an interesting question. Before getting into details, do you have a premium license?

@Paulie78  I do.

Paulie78
Super User
Super User

It's straightforward apart from extracting the link from the html. Do you have a sample of the HTML?

You can change the download link to something else if it is confidential.

@Paulie78  I don't know how much I can post on here publicly. But after looking at the html code email, the link is embeded like this below:

 

originalsrc="https://api.link_exmaple"

 

and I just need to extra the file from https://api.link_example, which when load the link itself, it will download the file itself.

Paulie78
Super User
Super User

Downloading the file is as easy as this:

downloadFile.png

You can then take the HTTP output and do whatever you want with it (save it to a folder). Your challenge is going to be grabbing the URL from the HTML. 

 

I can make an expression that gets the URL from the sample you posted. But it is very unlikely to work when you try it against your own proper example.

 

@Paulie78  Awesome, this is problem exactly when I will need.

 

I am thinking the first step of the flow is

1. when the e-mail account receives an email.

2. A condition, if the sender = the particular sender

3. extra the link from the e-mail; which the unique key in the e-mail will be "https://api......"   

(the text of https://api  is used in that link only, so I just need to create a string that extra the content between the quotation once it finds "https://api" 

 

then the rest of the steps will be what you posted above, I think. 

 

any tips on extracting the link text? 

Paulie78
Super User
Super User

No tips, just the expression:

substring
(
  substring(outputs('html'), indexOf(outputs('html'), 'https://api')), 
  0,
  indexOf(substring(outputs('html'), indexOf(outputs('html'), 'https://api')), '"')
)

linkIRL.png

Result:

linkURL-Result.png

@Paulie78 

lliu_western_0-1606959302085.png

the output from the get should be an csv file. But when I attached the "http body" as the attachment in the email, and email myself (just testing if the download file works), it is not a csv file. I think I am doing something wrong from getting the csv file using http call? 

@Paulie78 

lliu_western_1-1606959566316.png

this is the e-mail portion after http

 

Got it working now. I used "Create file" after HTTP and where the input of giving the file name, just have to make sure the file content is correct. So in my case, the "File Name" input needs to be something like "FileName.csv" since it is a csv file. 

lliu_western_0-1606964596963.png

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (4,124)