Attaching file to Outlook using wildcard

I’m trying to attach a file from a network folder using the “Send Outlook Mail Message”. When I click the “Attach Files” link I can hard code the directory including the file name and it works. The problem is that I need to be able to use a wildcard (*) at the end of the file name since the last part of the file name changes day to day.

I’ve tried entering an asterisk but it does not work.

“\VT-SQL04\Downloads\temp\bottemp\FILE_NAME_*.csv”

The error I get is: “Send Outlook Mail Message: File name or directory is not valid.”

Again, if I remove the * and type in the full file name it works fine.

Thank you for your help.

Hi
Welcome to uipath community

We won’t be able to mention like that buddy
Instead we can replace that part alone with a variable like this
VT-SQL04\Downloads\temp\bottemp\FILE_NAME_”+Now.ToString(“dd”)+”.csv”

Or based on the date format or any variable instead we have can be mentioned in that part along the filepath

Cheers @zigmo

Another way to get the file is to use the following command (assuming the file in the directory is the latest one):

System.IO.Directory.GetFiles(MyDirectory).Last

Does the “dd” part print the 2 digit number for the current day? Is Now a variable you build or a constant?

So if I need the current date to be 2012/01/01 would i type “yyyymmdd”? I’m new to all this so thank you for answering what I assume i a simple question.

This works perfectly for the current project. Thank you!

Is there a way to select the last 2 files?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.