Filter through unread emails in outlook, and open excel attachment

I am making a robot that needs to every 5 minutes filter through unread emails by a specific subject line, and then open the excel file that is attached to that email. I figured out how to filter through the emails but I do not know how to open the excel file because it is a different excel file every email.

1 Like

Also, I need to save the excel attachment to a folder before I open it

1 Like

Hi @dev.patel

You can use the save attachment activity to save the excel attachment in the local folder.
Then you can pass the same file path to the Excel activities to perform excel operations on excel.

Hope it helps!!

1 Like

Hi,

Once you read the mails.

Then use for each. Iterate your mail list. Inside for each use save attachment activity to save attament in specific folder.

Check this:-
https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://m.youtube.com/watch%3Fv%3D6r2U4Vl6Mv0&ved=2ahUKEwiuntamk--EAxU3iK8BHcL_C0EQwqsBegQIExAF&usg=AOvVaw1IeRPY3C2az3ulpDA7hefK

Thanks

1 Like

What would I put in the workbook path?

1 Like

After save attachments activity, insert an assign activity to get the recently downloaded file in a folder,

- Assign -> DownloadedFile = System.IO.Directory.GetFiles("YourFolderPath").OrderByDescending(Function(d) New FileInfo(d).LastWriteTime).FirstOrDefault()

Then DownloadedFile variable contains the recently downloaded file path you can pass that variable in the Workbook path in Use excel file activity.

Hope you understand!!

1 Like

@dev.patel

Save email attachments activity will have an output variable…which will give the path to downloded file

Use output(0) to get the filepath

Cheers

1 Like

When I assign DownloadedFile to the value you have there, it gives me an error message saying, “Assign: Could not find a part of the path ‘C:\Users\robmorgandev\Documents\UiPath\Maxon Serial Numbers-Dev\YourFolderPath’.”
What do I put instead of YourFolderPath
Sorry I am new to UiPath

1 Like

You have to give the folder path not file path.
Give the proper path in the folder path place in the expression, the path has to be within the double quotes… @dev.patel

Hope you understand!!

1 Like

I figured out how to open the excel file and read range however my next step is to delete duplicate rows from a specific column in the same data table. How would I do that?
Thank You

@dev.patel

you can use this

filtereddt = dt.AsEnumerable.GroupBy(function(x) x("ColumnName").ToString).Select(function(x) x.First).CopyToDataTable

cheers

What activity would that be?

@dev.patel

it is assign

cheers