Download attachement from latest mail only

Hello Forum,

I would like to download the attachment only from the latest mail from a sender.
I have used ‘Get Outlook Mail Messages’ activity and added the sender email address in the filter.
But the problem is, while using the ‘Save Email Attachments’ activity. Here I receive a Compiler error of Value of type ‘System.Collections.Generic.List(Of System.Net.Mail.MailMessage)’ cannot be converted to 'System.Net.Mail.MailMessage

Please find screenshot below of the workflow.
Can anyone please advise me on the right workflow to be followed ?
Thank you very much.


The output of GetEmail is a collection of emails. Even after you filter, you need to either add a for each to loop through that collection or use as an index (such as Listemail(0)). Because save email takes a single email.

Thank you for your reply @ChagantiAkhil . But this is exactly what I would like to avoid, using a ‘For Each’ activity. You see I need to only save the attachement from the most recent mail.

So, in the GetMail properties use the filter to get latest emails and get by newest first. So always the first email would be the latest one. And in the save email you can use Listemail(0)

1 Like

@ChagantiAkhil using ‘Listemail(0)’ works, Thank you. As information I found another work around as well : Use for each → Download document → break. Both solution seems to work :slight_smile:

1 Like

If you found this helpful, you can mark it as solution.


What if the most recent email isn’t the correct email? There could be spam or other emails that came in after it. The most reliable way to do this is to get the last X emails and loop through them looking at the subjects (or attachments) to find the one you want.

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