I have a for each loop to save attachments from Outlook to a destination folder.
Now, I want to open the attachment (Excel) and get the details.
I don’t know the excel file name. Is there a way to open the excel?
Try below expression to fetch the excel filename.
filename = Directory.GetFiles("Destination Folder Path","*.xlsx")(0)
It works!! Thank you.
Can I check what does (0) means at the back? Is it to fetch the latest excel in the folder?
1 Like
Hi @Cari ,
Here is another solution just to broaden your perspective.
If you want to retrieve the latest file from a given directory(str_downloadPath in this case), you can use this to achieve it →
Directory.GetFiles(str_downloadPath).OrderByDescending(Function(o) New FileInfo(o).LastModifiedDate).First()
Kind Regards,
Ashwin A.K
The above expression will give output as array of string. I.e. it will read all excel files from that folder. So, we are passing index as (0) to fetch the first file.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.