Save attachment and read excel dynamically

Hi all,
i need to read all email attachment, save it, read data inside this .xlsx and fill an online form, then, restart.
Now, i use save attachment inside a for each loop (for each mail) and the excel application scope to read mail.
My problem is, how can i read inside for each the attachment dinamically? For example save attachment 1, read attachment 1, and if i save an attachment with the same name? How can i fix it?

Hi @proto,

You could save the attachments to a specific folder, then use Directory.GetFiles in an Assign to get the one attachment in the file. See the below code:

FilepathString = String.Join("", Directory.GetFiles("Yourfilepath","*.xlsx",SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )

Once the process comes to an end you can delete the file and the process will be ready to run again. Or you can move it to another folder.

1 Like