How to download the specific attachments from outlook

Hi Everyone,
I want to check the email with subject Health Care forms if I have I have to download only the attachments Dental,CMS and UB.

can anyone suggest how can we do without looping.
I know that we can save the attachment and use for each and then save the specific attachment I need.
I don’t want to use save attachment twice.

Any suggestion pls directly how can I do it.

check the subject and download the required attachment Dental,UB,CMS

@Gayathri_Mk

you can use an expression like this

mails.Where(function(x) x.Subject.Contains("RequiredValue") AndAlso x.Attachments.Any(function(y) y.Name.Contains("RequiredName")))

if you want to check multiple attachments

mails.Where(function(x) x.Subject.Contains("RequiredValue") AndAlso x.Attachments.Any(function(y) {"Attachment1","Attachment2"}.Contains(y.Name)))

Or

mails.Where(function(x) x.Subject.Contains("RequiredValue") AndAlso x.Attachments.Any(function(y) {"Attachment1","Attachment2"}.Any(function(z) z.contains(y.Name))))

cheers


I am using get outlook mail messages can you guide me where to add this expression

Hello @Gayathri_Mk , Try this

  • Use Get Outlook mail and For each mail activity.
  • Assign the variable in the Get Outlook mail message and pass it to ForEach mail
  • Use the additional filter option and add the Filter condition to the Subject.
  • For each, use the Save attachment activity with Filter
  • Provide the Folder path to save the Attchments
 "*Dental*|*UB*|*CMS*"



I am getting this below error

@Gayathri_Mk

Mails in the above exprssion is the output of get outlook mail messages

Cheers

@Gayathri_Mk
Try this
Use For each with If condition to filter the Subject

currentItem.Subject.ToLower.Contains("subject in lower case")    

Note:  If subject "Hello Mail" Provide it as "hello mail"  as lowercase

Hello @Gayathri_Mk

  1. Get Outlook Mail Messages:

    • Output: mailMessages (List)
    • Filter: “Subject = ‘Health Care forms’”
  2. If (mailMessages.Any() AndAlso mailMessages(0).Attachments.Any()):
    3. Save Attachments:

    • Attachments: “Dental.txt,CMS.txt,UB.txt”
    • Folder: your desired folder path

Thanks & Cheers!!!

image
same error

@Gayathri_Mk ,
Apologies, I used it in Outlook scope.
Try this
Use If Condition to filter the Attachments and Subjects

currentItem.Subject.ToLower.Contains("subject in lower case") And currentItem.Attachments.Any(Function(attachment) attachment.Name.ToLower.Contains("dental") Or attachment.Name.ToLower.Contains("cms") Or attachment.Name.ToLower.Contains("ub"))

Thank you @Gokul_Jayakumar it worked now.

1 Like

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