Adding Mail Attachment names to a data table in a For Each loop

HI all

I have a for each loop to loop through and get all the names of the attachments in one email (because later on I need to loop through the names of the attachments and see if they contain key words, stored in another data table)

The For each loop is of the type and i’m looking at the attachments in a mail message type

I’m struggling to work out how to do this.

Any help would be really appreciated

@jordrowley Issue is with your add data row where exactly you are adding this. Do you have a instance of datatable created already for this.
Please share your workflow.

1 Like

@jordrowley Instead of using DataTable, simply store all the attachments name into List

1 Like

Thank you so much. That works.

Please can I ask if you know how I would do the next step

I would need to compare the value in the list with the value from a data table of two columns ‘Category’ and ‘Identifiers’

So if the value if the list matches the word in the category column (e.g ‘Colours’) the process will create a folder of that name and then can stop. If it doesn’t, it looks in the next column and if it finds the word Red, Blue or Green, the process will create a folder of that name and then end. If it doesn’t it does the same for the next row and so on.

Any advice would be amazing.
Thanks again

Thanks for the reply! - I’ve gone with the list solution below your reply. But I have another question around how you compare a value in a list to a value in a data table, if you can please see if you can help?

Thanks again,

@jordrowley you can use list.contains method in If condition. In case True then create folder and stop

1 Like

Hi @jordrowley
You can loop each item of list and execute below linq query in IF statement.
If value is true create folder, if value is false it will skip it.

(from dr as datarow in dt where dr.item("Category").ToString.ToLower.contains(item.ToString.ToLower) select dr).Count>0 or (from dr as datarow in dt where dr.item("Identifiers").ToString.ToLower.contains(item.ToString.ToLower) select dr).Count>0

1 Like

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