How to download attachments and send all attachments as one mail

  1. Search the last 10emails received whose subject contains " Progress Report"
  2. Download the attachments of all emails found
  3. Compose a new email and attach all the downloaded text files. Set email subject as " Progress Reports of Batch 1" and email body as “Please find the attached documents.”
1 Like

Hi @Tejaswini_Yadav ,

You can follow below steps:

1 - Use GetOutlookMail activity and in filter property mention as “[From] = '”+ yourString+“'” and Top property as 10
2 - Once you have all mails in collection from above output, iterate each mail one by one and download attachment from save mail attachment activity
3 - Use send mail activity to send another mail and attach all files path to Attachment collection.

Let me know if you have any question.

Hi @Tejaswini_Yadav

Hope these steps would help you resolve this

–use a GET OUTLOOK ACTIVITY or GET EXCHANGE MAIL ACTIVITY if outlook is not configured in your machine
–in that activity set the FILTER property as
"@SQL=urn:schemas:httpmail:subject like ‘%Progress%Report%’ "
and set the TOP property as 10 and get the output as out_mailmessages

–next to this mail activity use a FOR EACH activity where pass the above obtained variable out_mailmessages as input and change the type argument as System.Net.Mail.MailMessage

–inside the loop use SAVE ATTACHMENTS activity where pass the input as item to mailmessage property and mention the folder path where we need to save the attachment

–now use a SEND OUTLOOK or SEND EXCHANGE MAIL ACTIVITY and mention the subject and body as required in the property panel

and for all the attachments to be added
go to property ATTACHMENTCOLLECTIONS in that mail activity and mention this expression
Directory.GetFiles(“your folder path”)

Cheers @Tejaswini_Yadav