Email automation help with Link download and file transfer

Hi Folks,

I am looking to automate a manual task where in there is an email that comes from a tool (Cognos) with a URL link. I want to be able to open the email , click on the link and then move that download to a shared drive.

Hello @souravkayal ,

First get the mail message. Then get the URL from the body and using open browser, open that link. It will ask for the path, give the path and save the file.

Thanks!
Athira

can you share a workflow or show the steps, i am pretty new to this still. Thanks in Advance

Here you go:


The typeArgument of For each loop is System.net.Mail.MailMessage.
If there is any other content in the email body, make sure you are getting only URL value before massing it to open browser activity. After it opens, a pop u will come where you can give the path to save using ui automation.

Hope this helps.
Thanks

I am using Studio X and dont see these options.

In that case use this:



I am using “Use Application/Browser” activity to navigate to the url.

Thanks!

correct. I did that, now to move the dowonloaded file to another drive. Do i use move file ? if there are like 100 files

Yes. You can use move file activity inside the loop itself,

Thanks!

Thanks. But the file names will change with every download, how can i handle that

Hello,

How are you getting the file name ?

Thanks.
Athira

you have to try to find some pattern of the file name so that you can check or filter out the required files from the folder, like say I want all the pdf files present in “ABC” folder, then this code will give me a list of all file path which have extension as pdf and are presently inside folder “ABC”
Directory.GetFiles(“ABC” , “.pdf”)

Now you can use a for loop and iterate through the list of file names returned by the above code and use move file activity to move then to the required folder

Hope this helps :slight_smile:

The other major part of your question has been explained in a very detailed way by @athira.somasekharan

so when we download, the file name will change. For example if the first download is xyz.xlsx, second can be xyz1 or xyz123 etc.

Hello,

You can save all these files in the same folder and as @saurabhB mentioned, get all the files using Directory.GetFiles(FolderName) and loop through the list and move them one by one. Like this:

Hope this helps.
Thanks!
Athira

1 Like

is this action available in Studio X. I dont see it. I have for each file in folder but it has a different syntax

Hello,

Do like this in studioX:

Thanks!
Athira

So Athira, if i have multiple queries one below the other, do i download by clicking all individually or can we loop through

Hello,

Sorry, I didn’t get you. Can you please explain a little more?

Thanks!
Athira

So i am trying to download some files from cognos which are stored in queries. Like one below the other, do i need to set clicks for all or can i iterate it, file names and query names are different.

In that case, download all the files in a folder using for each loop through the excel. Then use for each file loop to move all the files like I mentioned above.

Thanks!
Athira

Hi Athira,
but all the files are in separate queries in cognos.