Tag Archives: email attachments to folders

Save emails and attachments to folders

With this post we will explore how you can save emails and attachments to folders using email rules.  Mail Attachment Downloader PRO and Free versions offer excellent functionality to solve these specific needs.

In our earlier blog post, we explored the many ways the PRO products can help you save time and money by getting data out of  emails.

The free version is for personal or trial use and offers some basic functionality to automatically save email attachments to folders.

The free version offers saving email attachments to a single folder. The PRO versions offer the ability to save not just the attachments but also entire emails to one or more folders.

The PRO Server also lets you run these tasks 24×7 unattended on a Windows Server or Azure cloud setup with ease.

Save emails and attachments to folders

The overall concept to save specific emails to distinct folders using our PRO Versions is to create different global rule filters, one per save location.

With each rule filter you would specify which emails to select for that specific rule filter and also specify a save location and filename.

Rules overview

The Global filters tab (only available in the PRO versions) offers the ability to create and manage more than one rule.

The rules are run top-down for each download session for the account selected in the Account section in the main program window. You can re-order rules as described in the tips below.


Important tips to rules:

  • Rules run per attachment / body: For every attachment and/or every body, the program will try to match every rule. Once a match is found, no other rules are run for that attachment or body. Note that other attachments in the email may match other rules based on the filters you have specified in the account.
  • Running rules: The rules in the Global filters tab is run for the account selected in the Account dropdown in the main window. To run the rules across many accounts, select multiple@multiple in the Account dropdown and then choose the accounts you want to run for. This will run all the rules every time for each selected account.
  • Restrict a rule to run only for one account: If you want a rule in the Global filter to only run for a specific account, you can do so as follows: In a rule (add new filter or edit selected filter), click on the Add -> Filters -> Account matches filter selection and then pick the account  from the dropdown and Save. Do this for each rule you want to restrict to that account.
  • Clone rules: If you find yourself creating many similar rules, an easy way to do this is to select a rule in the Global filters tab and then either double click or click on Edit selected filter. Then change the name of the filter to something different, click Save and choose No in the subsequent popup.
  • Re-order rules: Rules are run top-down and ordering is important. You can re-order rules by dragging and dropping the rule to the order you want. If an email or attachment matches all filters defined inside the rule, then subsequent rules are not run for that email or attachment.

Tips on naming rules

It is important that you name the rules in such a way that they are easy to find when creating many rules. Choose useful names when naming rules.

Lets say you are running a rule named “Invoices” but you are running this for only one account so you have added a Account matches filter in that rule, then it would be ideal to name the rule “someaccount@gmail.com – Invoices” so it is clear that this rule only applies to someaccount@gmail.com.

Then when you edit the filters in the Global filters, you can search for “someaccount@gmail.com” and only those rules that apply to someaccount@gmail.com will show up.

Create a rule with some filters

Create + Add new filter in the Global filters tab to create a new rule filter as shown earlier.

In the rule filter, specify a name for the filter first and then add a filter to determine which emails to save. In the example below we will filter based on the Subject.

filter by subject

Once the Subject filter is added, you can specify terms such as those containing certain phrases like  ‘Payments’ OR ‘Invoices’.

subject filter added

By specifying OR, the program will search for any emails with Payments or Invoices occurring anywhere in the Subject of the email and execute this rule.  You can also specify AND to ensure one or more terms all are included in the Subject (anywhere in the Subject). Or you can specify NOT to exclude certain emails.

Pick the save location and format

Pick the Save folder and the Saved filename format.

In the Save Folder, make sure you are using UNC paths and not mapped network drives when using the PRO Server product. 

Note that the Saved filename format can also include data from the emails like the {ID} or {SUBJECT} or {FROM} or {TO} or {DATE} an extracted field such as {ORDER_ID} and you can include these in the filename.

Use {ID} in the filename format:
{ID} is the unique ID given for each file. Ensure {ID} is always present in the saved filename format. Since the program uses multiple threads to download emails and attachments, removing {ID} will cause the program to fail when different emails have the same filename (this happens more often than you think as all email bodies are just named body.eml so if you do not include {ID} then you’ll just get one body.eml file and it would not work as desired).  

You can also specify \ to automatically create a folder based on say the {ORDER_ID} as shown below FY2016-Q3\{ORDER_ID}\{FILENAME}_{ID}{EXT}.


You can also create directories based on who the email was from like in the Free version. All you have to do is to specify something like: {EMAIL_FROM}\{FILENAME}_{ID}{EXT}. This will automatically create a directory for each FROM.

Similarly you can specify {EMAIL_SUBJECT}, {EMAIL_TO}, {EMAIL_CC} and many more. For a full list of options in the program, click the little (i) icon to the far right of the Saved filename format text entry. From the popup you can double click the field you would like to insert into the text area at the current cursor position.

We always recommend adding the {ID} to the filename ensure that files are saved with distinct names even if the name of the files are the same.

You can also save the email (Save as .eml checkbox) that will save the entire email as well instead of just the attachments.

Create multiple rules for different folders

Create multiple rules to match different emails and save them to different folders.

Perform actions after save

You can also then perform various advanced actions for each rule after the file is saved.

email actions

Uses and scenarios

Many businesses today use legacy extraction products to get data out of emails into folders (magic folders). Various other backend processes then pick up these files automatically to process them such as Scanning products, Invoice processing or invoicing related products, Document indexing products, Document archiving/management products,  OCR products and many more.

Further reading

Some interesting how-to links and posts for further exploration:

Contact us

Contact us if you have any questions, suggestions about the functionality described in this article.