Loop mails and use mail attachments in a Send Mail (Office 365)

I got an UiPath.MicrosoftOffice365.Models.Office365Message.AttachmentCollection I want to insert as an IEnumerable

In a “Microsoft Office 365 Scope” I use the action “Get Mail” which output an “Office365Message[ ]”

Then I do a “For Each” loop where the “TypeArgument” is set as “UiPath.MicrosoftOffice365.Models.Office365Message”.

Now I want to use “Send Mail” (UiPath.MicrosoftOffice365.Activities.Mail.SendMail) and take all attachements (if any) from the “Get Mail” action and insert as “Attachments Collection”.

Overview example image:

Detail images:

the attachmentCollection has items of the datatype: Attachment
the attachmentCollections from send Mail expects a List(Of String) with filepaths to the attachments saved on filessystem

to overcome you can save the attachments of the loop item and use later the file paths for the send Mail activity


We can use SaveAttachments activity in UiPath.Mail.Activities package even if variable type is Office365Message. And it returns IEnumerable<String>, as the following. We can use it in Attachment Collection property of SendMail activity.

Please note that please delete unnecessary files after send mails because SaveAttachments activity outputs files to file system.


Thanks PPR and Yoichi for the solution :+1:

1 Like

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