How to download mail attachments with specific subject

Hello,

my mail subject is “JWO Filles” and will always have 2 attachments.
my requirement is when mail will come in mailbox automation should downlaod 2 attahcments in folder.

how can i achieve that?
when i am draging get outlook mail activity i cant see any configuration to do
see below image-

help me on same

Hi @Mathkar_kunal,

You can achieve this using Get Outlook Mail Messages along with Save Attachments.

First, use Get Outlook Mail Messages and set the filter to "[Subject] = 'JWO Filles'" to fetch the required emails. You can configure this in the Properties panel (as shown on the right side). Then, loop through the retrieved emails using a For Each MailMessage activity. Inside the loop, use Save Attachments, pass the CurrentMailMessage, and provide your target folder path.

Optionally, you can add a condition to check CurrentMailMessage.Attachments.Count = 2 to ensure only emails with two attachments are processed.

If this helps, please consider marking it as a solution so it can help others as well.

Thanks!

not understood.
created variable email list . now where to pass it?

Hi,

You can remove the Get Outlook Desktop Mail Message.

Inside the Do block of the For Each Email, add an If condition. In the Then section, use Save Attachments and pass the CurrentEmail variable.

Thanks

what i need to write in if condition?

\i am doing like this but i cant see any attachment in folder

Hi @Mathkar_kunal,

You need to use If activity. Check the below snapshot.

Thanks

@Mathkar_kunal Please follow below steps and let me know if it works or not

  1. Drag Get Outlook Desktop Mail Messages activity into your workflow.

  2. Set Mail folder as "Inbox".

  3. In the Filter property, use:
    [Subject] = 'JWO Filles'

  4. Create an output variable for this activity, for example:
    out_Mails

  5. Drag a For Each activity after that.

  6. Set the type argument as System.Net.Mail.MailMessage.

  7. Use out_Mails in the For Each loop.

  8. Inside the loop, add Save Email Attachments activity.

  9. In MailMessage, pass the current mail item.

  10. In FolderPath, give the folder path where you want to save the attachments.

how to defind folder path ?
getting error
take ex i have to save in thois path -"C:\Users\kmathkar\OneDrive\Desktop\All Files\My data\New automation\Jira Workorders\Automation Files

Hi,

Just Copy the folder path and use it. "C:\Users\kmathkar\OneDrive\Desktop\All Files\My data\New automation\Jira Workorders\Automation Files

I am saving on desktop so using: Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

Thanks

ok reading mail but not downloadinga attchmnets

is you have used use application /browser and put everything in it?
and indicated outlook app?
i cant seee u have created variable out_mails in get outlook desktop mail message activity

@Mathkar_kunal I used application /browser and put everything in it and indicate outlook app. Please see the SS of the variable

ok but where u have passed this variable out mails.
i can see output variable is empty

@Mathkar_kunal Sorry i missed it. Please find the below SS

out_Mail = Variable type=System.Collections.Generic.List<System.Net.Mail.MailMessage>

it is going in else part , i have 2 attachments in mail

resolved able to downlaod attachments now