For Each Attachment in combination with Save Attachments doesn't work

I want to loop through all emails in a folder, then loop through all excel attachments in the email, saving each one to the desktop, processing it, and then remove the file.

Should be simple.

The picture above shows what I am doing. I only have one email, but it has two attachments, one is Excel and one is a jpg. I want to loop through each ATTACHMENT in the email and then save any that meet the condition that it is an excel file. However, the Save Attachments to Desktop action works on the MAIL message, not the item returned from the for each. But this makes no sense! I am looping through the attachments in the mail so the for each should return a file.

What is going on?

[As an aside, I know I can kind of get around this by putting in a filter for only XLS files in the save method, but I shouldn’t have to do that as I have already filtered for those files. And anyway, what if I have two or three or one hundred excel files in one email].


You can try this solution. If it is resolved, please mark it as resolved.

In my post I said that I know I can get around this by using the filter. However, the issue still remains. I am in a for each loop FOR EACH ATTACHMENT and so if there are 10 attachments I should loop through this 10 times and be able to process every attachment. Why is the type of the attachment an innumerable list? That makes no sense.

Hi Bryan,

looping through mail attachments works for me!

the type of attachment is System.Net.Mail.Attachment