How to filter outlook attachment file name?

Hi guys! I am currently a intern at local company. I just wanna ask you guys is there way to filter the attachment file name e.g. Tentative when downloading the attachments from outlook instead of the file type e.g. xlsx?

Thanks!

1 Like

@phoenix123

From outlook filter option, we can’t use filter attachments.

After reading mails from outlook using Get Outlook Mail Message activity and will give you output as List of Mail Messages. And then use For Each loop activity to iterate that list of mail messages.

ForEach item in mailMessage
If item.Attachments.Tostring.Contains(“xlsx”)
Then do some tasks
Else
Skip

1 Like

Hi @phoenix123

Usually in Get outlook mail activity we can check only a mail HAS attachment or not
we cannot filter based on the file in the attachment

So we need to get the mail message list and then only we can check with the attachment has a file of type we need or not
these are the steps to be followed to get this done

  1. Use get outlook mail activity and get all the mails you want with a variable of type mailmessage collections and name it as out_mailmessage
  2. Use a for each loop and pass the above variable as input and change the type argument as mailmessage
  3. inside the for each loop use a assign activity like this to get the name of the file attached (with file extension)
    out_attachmentName = CType(item.Attachments.FirstOrDefault, Attachment).Name
    this would give the name of file with extension that is attached to the mail list, where item is the variable obtained from the for each loop
  4. now use a if condition like
    out_attachmentName.ToString.Contains(“.xlsx”)
    if this condition gets passed it will go to the THEN part of if condition where you can save that attachment alone with save attachement activity where mention the mail input as item and mention the folder where you want to save
    thats all buddy you are done
    Kindly try this and let know buddy
    Cheers @phoenix123
3 Likes

@Palaniyappan @lakshman hey guys! Thanks for your contribution for the solution and your effort for helping me looks like your are right, outlook activity can only filter file extension type instead of the file name. So, thanks once again! :slight_smile:

2 Likes

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