Customizing file names or email data using fields

Build folder and file names from email fields such as {FILENAME}, {ID}, the sender and the date, with date formats and examples.

Mail Attachment Downloader names the files it saves from fields: short names in curly braces, such as {SUBJECT} or {DATE[yyyy-MM-dd]}, that are filled in from each email. This post lists the fields of version 4.0, shows how to change their output, and gives a few examples.

Where you can use fields

  • A rule’s folder and file name (PRO Rules Client and PRO Rules Server): the Save folder and File name boxes of the rule’s Save part, in the Rule Editor.
  • The text of a rule’s steps: for example the file and columns of Save metadata, the subject and text of Send an email, or the file name of Merge PDFs.
  • The Parser’s output (PRO Parser and up): its folder and file name can use the values the Parser reads, such as {SUPPLIER}\{INVOICE_NUMBER}_{FILENAME}{EXT}. See folders and file names.

The Free edition and PRO Backup name files with tick boxes instead: on the Account rule tab, the Folders and file names page has Saved file name with Filename, From, Subject, Date and ID, to make each name unique.

How to open the field list

Click the Fields… button next to a box. The Fields window lists each field, what it holds, and its value for a sample email. Type in the search box (for example “date” or “sender”) to find a field, then click Insert to put it where the cursor is. Fields: help explains more.

The Fields window open under a rule's File name box: a search box, the columns Field, Holds and For a sample email, {EMAIL_FROM} selected and the Insert button
Fields…: every field the box can use, with its value for a sample email.

The list only offers the fields that make sense in that box. A rule’s File name can’t use the saved file’s own fields, such as {SAVE_PATH}, because the file isn’t saved yet.

The default file name: {FILENAME}_{ID}{EXT}

A new rule starts with this file name:

{FILENAME}_{ID}{EXT}

  • {FILENAME}: the file’s name, without its extension.
  • {ID}: the message’s ID with the part number, so each file’s name is different.
  • {EXT}: the file’s extension, with the dot, such as .pdf.

So invoice.pdf is saved as something like invoice_00000_1.2.pdf. Keep {ID} in your file names: two emails often send files with the same name (invoice.pdf, scan.pdf), and {ID} keeps them apart. Use {FILENAMEEXT} for the name with its extension, but not together with {FILENAME} and {EXT}, or part of the name comes twice.

The Save part of a rule with the default file name {FILENAME}_{ID}{EXT} and an example of the saved file's path below it
A new rule’s file name, with an example of the result below the box.

The fields

The email

  • {FROM}, {TO}, {CC}: who sent it, who it was sent to and copied to, with the names.
  • {EMAIL_FROM}, {EMAIL_TO}, {EMAIL_CC}: the addresses only (several are separated by commas).
  • {SUBJECT}: the subject.
  • {IMPORTANCE}: HIGH, NORMAL or LOW.
  • {EMAIL_HEADER[...]}: any header of the email (more below).
  • {MESSAGE_ID}: the message’s ID, without the part number.
  • {ATTACHMENT_COUNT}: how many attachments the email has.

Dates

  • {DATE}, {DATE_LOCAL}, {DATE_UTC}: the email’s date as the email has it, in this computer’s time, or in UTC.
  • {PROCESSED_DATE[...]}, {PROCESSED_DATE_LOCAL[...]}, {PROCESSED_DATE_UTC[...]}: when the email was processed.

The file

  • {FILENAME}, {EXT}, {FILENAMEEXT}: the file’s name, its extension, and both.
  • {ID}: the message’s ID with the part number. {IDS} is the same, but filled even when {ID} is already in the name (then {ID} is empty).
  • {PART_NUM}: the part number of the attachment or the body.

The account and folder

  • {ACCOUNT_EMAIL}: the account it was downloaded from.
  • {MAILBOX_FOLDER}: the mailbox folder’s full path. {MAILBOX_SUB_FOLDER}: the folder’s own name, without its path.
  • {ACCOUNT_FOLDER}, {ACCOUNT_MAILBOX}: the folder’s path in the account, and the mailbox (a shared mailbox or group for Exchange).

Only in steps

  • {SAVE_PATH}, {SAVE_FILE}: the folder the file was saved in, and its full path and name.
  • {OFILENAME}, {OEXT}, {OFILENAMEEXT}: the attachment’s name as it was sent.
  • {CLOUD_URL}, {CLOUD_PATH}, {CLOUD_FILENAME}: for the steps under Upload to cloud: where the file went.
  • {EMAIL_BODY}, {EMAIL_BODY_HTML}, {EMAIL_BODY_SOURCE}: the email’s text or HTML, in boxes such as an email’s text, a web hook or an AI prompt.
  • {ERROR_MESSAGE}: the error, in the steps under If something fails.

Your own fields

Values a rule finds under Fields to find, or the Parser reads, become fields too, such as {INVOICE_NUMBER} or {ORDER_ID}. They show at the end of the field list. See extract data from emails and attachments.

Customizing a field’s output

Most fields are simply filled in. A few take a setting in square brackets.

Date formats: DATE, DATE_LOCAL, DATE_UTC and PROCESSED_DATE

Put a format in square brackets. For example {DATE[yyyy-MM-dd]} gives 2026-04-23: the date only, without hours, minutes and seconds. {DATE_LOCAL[yyyy-MM]} gives the year and month in this computer’s time. The formats are .NET’s custom date and time formats.

For a folder for each year with a folder for each month inside, put two date fields with a \ between them: {DATE_LOCAL[yyyy]}\{DATE_LOCAL[MM]} gives 2026\04. A \ inside the square brackets doesn’t make folders.

{DATE} without a format is the date as the email has it, with commas, colons and the time zone. In names, prefer a format.

EMAIL_HEADER[…]

Put the header’s name in the square brackets: {EMAIL_HEADER[message-id]}, or a header your supplier adds, such as {EMAIL_HEADER[X-Invoice-Number]}.

ATTACHMENT_COUNT[‘.pdf’ OR ‘.xml’]

Counts only the attachments whose names match, such as {ATTACHMENT_COUNT['.pdf' OR '.xml']}. Add the extensions or names you need. To pick emails by the number of attachments, use a condition instead: More attachments than or Fewer attachments than, with Counting only files named:. Conditions don’t fill in fields: they match the text as you type it.

What a name can’t hold

In folder and file names, a field’s value is cleaned up to make a valid name: \ and : become _, / becomes -, and " ? * | # are left out. Only a \ you type makes folders, and so do the folder fields: {SAVE_PATH}, {SAVE_FILE}, {MAILBOX_FOLDER}, {ACCOUNT_FOLDER} and {ACCOUNT_MAILBOX}.

Everywhere else (a database, a CSV file, an email, a web hook or an AI prompt) fields are filled in exactly as the email has them.

Examples

Example 1: a daily log of all files saved

Want a CSV file each day that lists the files saved and the emails they came from? Add a Save metadata step under Then (PRO Rules Client and up):

  • File: \\fileserver\Finance\Logs\{PROCESSED_DATE_LOCAL[yyyy-MM-dd]}.csv. The date has the day only, so every file saved that day goes into the same CSV.
  • Columns: for example {FILENAMEEXT},{EMAIL_FROM},{SUBJECT},{DATE[yyyy-MM-dd]}.
  • Tick Add to the file when it is there (otherwise replace it).

The next day starts a new file. Put the same step in each rule whose files you want in the log.

A Save metadata step in the Rule Editor with a File box, Columns built from fields, and Add to the file when it is there ticked
The Save metadata step: a file name and columns built from fields. Put a date in the file name to start a new log each day.

Example 2: a folder for each month, files named by sender

  • Save folder: \\fileserver\Finance\Invoices\{DATE_LOCAL[yyyy]}\{DATE_LOCAL[MM]}
  • File name: {EMAIL_FROM}_{FILENAME}_{ID}{EXT}

An invoice from ap@acme.example received in April 2026 is saved in \\fileserver\Finance\Invoices\2026\04, with the sender’s address at the start of its name.

Example 3: merge an email’s PDFs into one

The Merge PDFs step (PRO Rules Server) joins an email’s saved PDF files into one, with a File name built from fields, such as {SAVE_PATH}\{DATE[yyyy-MM-dd]}_{SUBJECT}_{ID}.pdf: one PDF for each email, in the folder its files were saved in. Start the name with {SAVE_PATH}\, so the PDF goes there. Emails of the same download that get the same name are joined into one file. A merged file from an earlier download is replaced, not added to, so processing the same emails again gives the same PDF.

The Rule Editor with a Merge PDFs step that joins the email's saved PDF files into one, named from the date, the subject and the ID
A Merge PDFs step, with a file name built from fields.

Try it: download Mail Attachment Downloader and start with the free edition, or compare the PRO editions, each with a 30-day money-back guarantee.

Related

Using version 3.x? See the 3.x version of this guide.

Questions or suggestions about this post? Contact us.

Support for modern authentication in Outlook, Microsoft 365, Exchange and Google

How Mail Attachment Downloader signs in to Microsoft 365, Outlook.com, Exchange and Gmail with modern authentication, and what IT needs to know.

Mail Attachment Downloader signs in to Microsoft 365, Outlook.com, Exchange Online and Gmail with modern authentication (OAuth 2.0). You sign in on Microsoft’s or Google’s own page in your browser, and the program never sees your password. It keeps only the sign-in (a token), encrypted for your Windows account.

This post covers version 4.0. Everything here is in the Free edition too, except where it says PRO.

New in 4.0

  • A tile for each big provider: Gmail, Outlook.com, Microsoft 365, Yahoo, AOL, Exchange and Other. Type your address and the right one is picked, also on your own domain: the program looks up its mail records.
  • The Microsoft 365 tile connects with Microsoft Graph, the way Microsoft recommends.
  • Sign in in a Private window, so an account your browser is already signed in to isn’t used by mistake. The Permissions tab shows what was Requested and Granted.
  • Setup guides for 150+ providers that need an app password, and a plain explanation when a provider turns a password down.

Which settings should I pick?

Your emailTileConnects withHow you sign in
Microsoft 365 (work or school)Microsoft 365Microsoft GraphMicrosoft, in your browser, or App registration (PRO)
Outlook.com, Hotmail, LiveOutlook.comIMAPMicrosoft, in your browser
Gmail, Google WorkspaceGmailIMAPGoogle, in your browser, an app password, or App registration (PRO)
Exchange on your own serverExchange, with On-premises only tickedExchange Web Services (EWS)Your password, or Windows sign-in
Yahoo, AOL, iCloud and othersYahoo, AOL, or OtherIMAPAn app password, with the setup guide

A Microsoft 365 account can also use Use IMAP instead or Use Exchange Web Services instead on the Server tab, still signing in with Microsoft. Prefer Microsoft Graph: Microsoft is switching EWS off in Exchange Online (from October 2026, and removing it in April 2027, by Microsoft’s schedule). If an older Microsoft 365 account still uses EWS, pick the Microsoft 365 tile and sign in again.

The Mail account and server configuration window with the Microsoft 365 tile picked from the email address, a browser sign-in, and the Server, Sending mail, App registration and Permissions tabs
The account’s settings: the tile is picked from your address, and Microsoft 365 connects with Microsoft Graph.

Signing in with your browser

  1. Click Add account and type your address in Email address. Check the tile against the table. With a browser sign-in, there is no password box.
  2. Click Test Connection. A sign-in window opens, then your browser. Pick Private window if your browser is signed in to another account.
  3. Sign in as the same account and allow every permission. On Google, tick every checkbox: unticked boxes aren’t granted.
  4. Go back to the program. It continues by itself and shows Connection works. Click Save.

If the browser didn’t open, click Browser didn’t open?. Keep Remember ticked so scheduled downloads can sign in by themselves. For a Microsoft 365 shared mailbox, tick This is a shared mailbox on the Server tab (PRO).

The Sign in to Microsoft 365 window for finance@contoso.com: steps Sign in with Microsoft, Allow access, Continue; Use my default browser, Private window, waiting for the browser, Browser didn't open?, the permissions the app asks for and Copy for IT
Signing in to Microsoft 365: the program waits while you sign in in your browser, and lists what it asks Microsoft for.

Yahoo, iCloud and others: app passwords

Yahoo, AOL, iCloud and many other providers don’t offer OAuth to other programs. They need an app password: a separate password for one program, which you can cancel without changing your main one. Gmail accepts one too if 2-Step Verification is on, but the browser sign-in is easier.

Type your address, then click Set up <provider>… in the note under Sign in. The guide opens the provider’s page to create the password, checks what you paste, and tests it. Click Use this password, then Save the account. See what each provider needs.

The Set up AT&T Mail guide: open the provider's help, paste the secure mail key, test the connection, and Use this password
A setup guide: open the provider’s page, paste the password, test it, then “Use this password”.

Typed your regular password instead? The program explains what the provider wants: click Open setup guide.

Yahoo Mail turned down the sign-in: Yahoo only accepts an app password, with How to fix it and an Open setup guide button
When a provider turns down a password, the program says what it needs.

For IT administrators

By default the program signs in to Gmail, Outlook.com and Microsoft 365 through our own app, and each user grants it access. Most organizations only need to grant admin consent once. The sign-in window’s Copy for IT button copies the account, the client ID and the permissions requested, never passwords, tokens or secrets.

Built-in Microsoft app: Mail Attachment Downloader, client ID 327a7151-62e7-4ab6-af0a-55120ca90505, a multi-tenant desktop app with delegated permissions only and no client secret.

PermissionUsed for
Mail.ReadWrite, Mail.SendMicrosoft Graph: reading, moving and marking email, and rules that send email
Mail.ReadWrite.Shared, Mail.Send.SharedShared mailboxes only (PRO)
IMAP.AccessAsUser.All, SMTP.SendMicrosoft 365 and Outlook.com over IMAP
EWS.AccessAsUser.AllExchange (EWS) only
https://mail.google.com/Gmail over IMAP. Google has no narrower IMAP permission.
offline_accessStaying signed in for scheduled downloads

Your own app registration (PRO): pick App registration under Sign in and fill in the App registration tab. For Microsoft 365 (Graph, EWS or IMAP), a Client ID, Client secret and Tenant ID give app-only access, which password resets and sign-in policies don’t stop. For Gmail and Google Workspace, enter your own Google Cloud OAuth client; users still sign in once, through your app. It isn’t available for POP3, Exchange on your own server or personal Microsoft accounts. Guides: Microsoft Entra and Google Workspace. Read the security notes on app-only access first.

A Microsoft 365 account's window with App registration chosen: Client ID, a kept client secret and Tenant ID, made-up values
Your own app registration: Client ID, Client secret and Tenant ID.

The Windows service (PRO Rules Server): browser sign-ins go with the service when it is installed. If one is revoked later, sign in again in the program, then click Reinstall… on Schedule › Service schedule. For Microsoft 365, app-only access avoids this.

Connection or sign-in problems?

Read the message above Test Connection: it gives the mail server’s own words. Then open Troubleshoot › Connection diagnostics, which shows each stage of the latest sign-ins with timings and the error.

What you seeWhat to do
“Some permissions weren’t granted”Sign in again and allow every permission. See granting the permissions.
Microsoft asks for admin approval, or 403 ForbiddenSend your IT team the Copy for IT text and this post.
Signed in as the wrong accountSign in again in a Private window.
A Gmail or Microsoft account keeps failingTroubleshoot › Clear saved sign-in, then Test Connection.
A Microsoft 365 account on EWS stopped connectingPick the Microsoft 365 tile and sign in again.

Still stuck? Tick Verbose logging in Settings › Logs and support, try again, and click Submit a bug report…. Reports leave out passwords and tokens.

Free and PRO

Browser sign-in, the setup guides and Connection diagnostics are in the Free edition. The PRO editions add shared mailboxes, your own app registration, sending mail from your accounts (for rules and email notifications), and, from PRO Rules Client, uploads to OneDrive and SharePoint, which sign in on their own in Cloud connections.

Related

Using version 3.x? See the 3.x version of this guide.

Feedback on sign-in? Contact us.

Nesting email rules and actions: shared filters, negative rules and steps inside steps

Chain rules under a shared filter, catch unsaved emails with a negative rule, share steps between rules and nest steps inside steps.

This post shows how to nest rules and steps in PRO Rules, the rules of PRO Rules Client and PRO Rules Server. It is written for version 4.0.

You don’t need nesting for most jobs. One rule with its conditions, its save folder and a few steps does the work. Nesting helps in advanced cases, such as:

  • When no rule saved anything from an email, do something else with it, such as moving it to a folder you check by hand.
  • When the attachments of one email each need different handling.
  • When many rules share the same conditions or the same steps, and you don’t want to type them again in each rule.
  • When a step should work on the result of another step: the files of a zip, or a converted PDF.

New to PRO Rules? Read save emails and attachments to folders first. It walks through a whole rule. In version 3.x the PRO Rules tab was called Global filters.

Nesting rules: the four rule types

Each entry in the PRO Rules tab has a Rule type. You pick it with the arrow next to New rule…, or later with Rule type: in the rule’s Save part.

  • Global rule: the usual rule. It saves what matches its conditions, then runs its steps.
  • Shared filter: only conditions. It saves nothing and runs no steps of its own. Other rules use its conditions, and they show under it in the list.
  • Negative rule: steps for the emails nothing saved. It saves nothing: its steps run for the emails no rule saved anything from.
  • Shared action: steps that other rules run. It saves nothing, and its steps run when another rule runs it.

Shared actions are always listed first. The rules and shared filters below them run in the order of the list, and the rules under a shared filter run right after it.

The PRO Rules tab with a shared action at the top, a Supplier invoices shared filter with two rules under it numbered 1.1 and 1.2, and three more rules
A shared action (S1), listed first, and a shared filter (1) with two rules under it (1.1 and 1.2).

Example: one shared filter, three rules and a shared action

Say Acme, Northwind and Fabrikam send emails with “Invoice ID” in the subject. You want to:

  • save their PDF attachments to \\fileserver\Finance\Invoices\PDF,
  • save their Word attachments to \\fileserver\Finance\Invoices\Word,
  • move an email with neither to an “Issues” folder of the mailbox,
  • and record the email’s details in a database for each saved file.

Turn PRO Rules on first: tick Use PRO Rules for every account at the top of the PRO Rules tab.

1. The shared filter

Click the arrow next to New rule… and pick Shared filter – filters only, no actions. Name it “Invoice ID emails”. Click Add a condition, choose Subject and type 'Invoice ID'. Click Save.

The shared filter decides which emails the rules under it see. It saves nothing by itself.

2. A rule under it for the PDFs

Open the shared filter’s menu (its + button, or right-click it) and choose Add a rule under this shared filter › Global rule – filters and actions. The new rule gets a Use a shared filter condition for “Invoice ID emails”, so it only runs for the emails that filter matches.

  • Name it “Invoice PDFs”.
  • Add an Attachment name condition with '.pdf', so only PDF files match.
  • In Save, pick The attachments and set the Save folder to \\fileserver\Finance\Invoices\PDF.
  • Under Then, click Add a step… and add Mark as read. You could add Move or copy the email instead.

3. A second rule for the Word files

Do the same again: Add a rule under this shared filter › Global rule – filters and actions. Name it “Invoice Word files”, use '.doc' (it also matches .docx) in the Attachment name condition, and save to \\fileserver\Finance\Invoices\Word.

The PRO Rules tab now shows the shared filter as 1, with the two rules under it as 1.1 and 1.2.

4. A negative rule as the catch-all

From the shared filter’s menu, choose Add a rule under this shared filter › Negative rule. Name it “Invoice ID emails with no files”. A negative rule saves nothing, so you only give it steps.

Under Then, add Move or copy the email and pick the “Issues” folder of the mailbox. Now an “Invoice ID” email from which no rule saved anything is moved there for you to look at.

5. A shared action for the database

Click the arrow next to New rule… and pick Shared action. Name it “Save email details to the database”. Under Then, add Save to a database and set it up. See save emails and attachments to a database; we won’t repeat that here. Save to a database needs PRO Rules Server. With PRO Rules Client, use a step such as Upload to cloud or Copy file in the shared action instead.

Now let the two rules run it. Select “Invoice PDFs” and “Invoice Word files” in the list, then choose Rule settings › Shared filters and actions › Add ‘Shared action’ to selected, and pick the shared action. Another way: open the shared action’s menu and use Make a rule run it.

Each rule now has a Run another rule step under Then. It runs the shared action’s steps there, for the same email and file. You can also add that step yourself with Add a step….

What you have

  • The shared filter picks the emails with “Invoice ID” in the subject.
  • Its two rules save the PDF and Word attachments to their own folders, mark the email as read, and run the shared action.
  • The shared action records the email’s details in the database for each saved file.
  • The negative rule moves an “Invoice ID” email to “Issues” when no rule saved anything from it.

Before the first real run, click Rule settings › Test all rules…. It runs the rules that are on, on emails you pick, and shows which rule saves each file. Nothing is changed: files go to a temporary folder, and moving, marking as read and other outside steps are only described.

The PRO Rules tab: shared action S1 Save email details to the database, shared filter 1 Invoice ID emails with the rules 1.1 Invoice PDFs, 1.2 Invoice Word files and the negative rule 1.3 under it, and the shared filter's menu at Add a rule under this shared filter
The example in the PRO Rules tab: a shared action, and a shared filter with three rules under it.

Nesting steps: steps inside steps

Steps under Then run in order, from the top. A step can also hold steps of its own. The steps inside it work on its result: the files of a zip, the PDF a conversion made, the fields an AI found.

Steps that can hold steps include Unzip, Convert documents, Make PDFs searchable (OCR), Find fields with AI, Copy file, Upload to cloud, Save to a database and Web hook.

To put a step inside another one:

  1. In the Rule Editor’s outline, select the step that should hold it, for example Unzip.
  2. Click Add a step….
  3. In the Add it: box, choose Inside “Unzip”. The other choices are after the selected step, At the end of Then and At the end of If something fails.
  4. Pick the step and click Add.

To move a step, drag its row: drop it between two rows, or on a group, If a field… or For files named… to put it inside. Move up (Alt+Up) and Move down (Alt+Down) work too.

The Rule Editor with Make PDFs searchable (OCR) under Then, Find fields with AI inside it, and Save to a database, Web hook, Upload to cloud and Send notification inside that, then Move or copy the email and an If something fails part
Steps inside steps: OCR, then fields found by AI, then four steps that use those fields.

In the picture, Make PDFs searchable (OCR) reads each scanned PDF. Find fields with AI, inside it, reads the searchable PDF and fills {INVOICE_NUMBER}, {DUE_DATE} and {TOTAL_INCLUDING_TAX}. The four steps inside that use those fields. Move or copy the email is back at the top level of Then, after the OCR step and everything inside it.

Another example: Unzip a zip of invoices, then Convert documents inside it to make a PDF of each file, then Save to a database and Run a command line inside that. See unzip, convert to PDF and run a script for that one, step by step. OCR, Unzip, databases, web hooks and command lines need PRO Rules Server.

Decide inside a rule

The Decide and repeat kind of steps in Add a step… lets part of a rule run only sometimes, while the rest goes on as usual:

  • If a field… runs the steps under it only when a field is empty, not empty, or matches. For example, upload only when an invoice number was found.
  • For files named… runs the steps under it for the saved files whose names match, such as only the PDFs.
  • Group of steps keeps steps together, in order.
  • Run another rule runs a shared action’s steps here.

When the files go to the same folder and only their steps differ, For files named… can replace a shared filter with two rules: one rule saves the attachments, then runs one set of steps for the PDFs and another for the Word files.

The Add a step window on the Decide and repeat kind: If a field..., For files named..., Group of steps and Run another rule
Add a step… › Decide and repeat.

If something fails

Below Then, each rule has If something fails. Its steps run when a step above fails. Use the {ERROR_MESSAGE} field to say what went wrong.

  • With PRO Rules Client: Move or copy the email, Delete the email or Mark as read.
  • With PRO Rules Server, also: Send an email, Send notification, the database steps, Run a script and Run a command line.

New in 4.0: a step that fails is tried again by itself, after a wait, and a failed step holds back the steps below it until it works. By default the steps under If something fails run once the program has given up on the step. Change that, and the number of tries, in Settings › Retries, or for one rule with the Retries… button in its Save part.

Points to remember

  • Rules run from the top of the list. The first rule that matches a file saves it, and the rules below it don’t see that file.
  • Shared filters, negative rules and shared actions save nothing. Only global rules save files.
  • Test with Test this rule… in the Rule Editor, or Test all rules…, before you rely on a rule.

Try it: download Mail Attachment Downloader and start with the free edition, or compare the PRO editions, each with a 30-day money-back guarantee.

Related

Questions or suggestions about this post? Contact us.

Why did my rule not download the attachment or email? Troubleshooting PRO Rules

Why a rule didn’t save an attachment or email, and how to find out: Downloads, History, Test this rule, Check rule order and rule tracing.

This post goes through the steps to find out why a rule didn’t download an attachment or an email, and how to fix it. It is written for version 4.0.

It covers PRO Rules, the rules of PRO Rules Client and PRO Rules Server. In version 3.x the PRO Rules tab was called Global filters. Using the Free edition, or a PRO edition without PRO Rules? Each account then has one rule, in the Account rule tab: see the how-to page.

New to PRO Rules? Read save emails and attachments to folders first: it walks through the parts of a rule. For rule order and the catch-all rule, see rule order, the catch-all rule, and turning rules on and off.

Version 4.0 has much better tools for this than 3.x had. Use them in this order.

1. Use the latest build

Many problems are already fixed. The build you have is shown at the top of the main window, next to the edition, for example “PRO Rules Server 4.0 · build 1080″. See get the latest build. Your settings and rules are kept when you update.

2. Look at the Downloads tab

After a run, open the Downloads tab. With Emails picked at the bottom, each email has a State that says what happened to it, such as how many files were saved. Click the arrow at the start of a row to see the email’s details: which rule saved each file, and, when nothing was saved, why. For example:

  • “Nothing saved: no rule took its attachment (the rules’ file types, sizes or filters leave it out)”.
  • “Nothing saved: its only file is an inline image (a picture inside the text), and no rule took it”.
  • “Nothing to save: this email has no attachments or inline images, only its text.”

Pick Files to see each saved file, its folder and the rule that saved it. The filters show one Rule, or Failures only. Runs shows one run at a time, and History all of them. If you use the Windows service, set View to The service to see its work.

An account that can’t run until you fix something, for example because its sign-in expired, is listed under Action required.

The Downloads tab after a run: Runs, This run, a list of invoice and purchase order emails with their State, Saved 1 file, and the Emails and Files buttons
The Downloads tab: each email and what was saved from it.

3. Was the email already processed?

New in 4.0: each account has a History. It remembers each email the account has seen, so nothing is downloaded or processed twice, even when you search All mail.

That matters when you fix a rule. The emails the account has already processed are not run through the changed rule by themselves. To run them again:

  • A few emails: pick them in the Downloads tab and choose Process again…, then The whole email, with the rules as they are now. The rules run again over the email’s stored copy. Files saved before are replaced, and nothing is moved, copied or deleted in the mailbox again.
  • Many emails: click History at the top of the main window and choose Redo…. It downloads or processes again the emails you choose, by dates, folder, rule or state.

A step that failed, such as an upload when the network was down, is tried again by itself after a wait. To try it now, pick the email and choose Try again now, or Process again… › Only the steps that failed. What already worked is not done twice.

4. Test the rule, without changing anything

This is the quickest way to see what a rule does with a given email:

  • In the Rule Editor, click Test this rule…. It runs the rule as you have it, unsaved changes included.
  • In the PRO Rules tab, click Rule settings › Test all rules…. It runs the rules that are on, in the list’s order, as a download does.

Choose the accounts and folders, choose which emails (for example Today’s emails or a date range), click Find items, tick the emails and click Run test. Nothing is changed: files go to a temporary folder, and moving, deleting, marking as read, sending and other outside steps are only described.

The Result column says what happened to each email. Test this rule says Matched, Not matched, Matched, nothing saved, or “Taken by” a rule above it, which saves the file first. Test all rules says which rule saves the files (“Saved by ‘Invoice PDFs'”), or No rule matched. Click an email to see which rule saves what, and which condition didn’t match. Open in trace viewer shows every condition. Have the email as a file? Test an email file… tries the rule on an .eml or .msg file.

Test rule 'All PDFs': five sample emails with the results Taken by 'Invoice PDFs', Matched and Not matched, and the details of invoice INV-2026-0423 below
Test this rule: the invoice is “Taken by” the rule above, so this rule never sees it.

5. Check the rule order

Rules run from the top of the list. Each file is saved by the first rule that matches it, so the rules below that one never see it. This is the most common reason a rule “does nothing”.

Click Rule settings › Check rule order…. It finds the rules that never save anything because a rule above them takes all their files, and offers to move them, for example Move “Northwind statements” above “All PDFs”. Or drag a rule up or down in the list.

The rule order check: Northwind statements never saves anything because All PDFs above it takes its files, with a button to move it above All PDFs
Check rule order: one click moves the rule that never gets a file.

6. Trace a real download

When a test looks right but a real download doesn’t, trace it:

  1. In the PRO Rules tab, open Diagnostics and tick Rule tracing.
  2. Click Connect and Download and let the run finish.
  3. Click Show the traces….
  4. Pick a download session: the time the run started.
  5. Untick “Use the tree view”. Select the email that should have saved something, then the file name in the email, then a rule.
  6. The Matched? column shows each of the rule’s conditions, by their inner names (EMAIL_FILENAME is the attachment name, EMAIL_FROM the sender). If one says No, that condition is why the rule didn’t save the file.

Tracing slows downloads, so untick it when you are done. The traces are kept in memory only, for the last 1000 emails, so read them before you close the program.

The Rule trace viewer: an Acme invoice email picked, its file INV-2026-0423.pdf and the rule Acme invoices, with the file name condition showing Matched? No
The trace shows the one condition that failed: the file name doesn’t contain “invoice”.

Common causes

Most rules that don’t download have one of these causes:

  • PRO Rules aren’t on. Tick Use PRO Rules for every account at the top of the PRO Rules tab. Until then each account’s Account rule decides.
  • The rule is off, or a draft. Check the Enabled column. A draft shows Draft: doesn’t run until you save it as a rule.
  • A rule above takes the file. See step 5.
  • The rule is for another account. An Account condition limits it to one account. A rule under a shared filter also needs that filter’s conditions to match.
  • The email is older than the search. On the PRO Rules tab’s Search scope page, Messages since last download skips older mail, and Only emails from and Only emails up to limit the dates for every account. For emails the account has already seen, use Redo… (step 3).
  • The email is in another folder. The Folders to search pane says which folders are searched, for example “Only the Inbox is searched.” Click Choose other folders…. POP3 accounts have no folders: switch the account to IMAP if your mail server has it.
  • The file is inline. Pictures and some files sit inside the email’s text. Turn on Inline content (slower): on the Search scope page, or in the account’s own settings.
  • The file is inside an attached email. Tick Look inside them too under Attachments that are emails on the Search scope page.
  • The file type is left out. Check Only files of these types in the rule’s Save part, and its Attachment name conditions.
  • The email has no attachment. To save the email itself, What to save must be The email and its attachments or The email only.
  • A field in a condition. Conditions match the text exactly as you type it. A field such as {DATE} in a condition is not filled in, so it never matches. The Rule Editor warns about this.
  • The email never arrived. Turn on Expected emails for the rule and tick Check for missing emails. The program learns when the emails normally arrive and shows Late or Missing when one doesn’t. Steps under If an email is missing can tell you.
The Rule Editor on Expected emails: Check for missing emails ticked, monthly on days 1 to 3 at about 9:00 AM learned from 11 emails, split by sender, late after 30 minutes
Expected emails: know when an email you count on doesn’t arrive.

Using the Windows service?

With PRO Rules Server, the service keeps the copy of your settings and rules it got when it was installed. If a download in the program works but the service doesn’t, you probably changed something since. Open Schedule › Service schedule: it shows Reinstall to apply changes. Click Reinstall…. See service and configuration changes.

To try a rule while the service is installed, use Test this rule… or Test all rules…: they change nothing.

Still stuck?

Open Settings › Logs and support, tick Verbose logging, make the problem happen again, then click Submit a bug report…. Passwords, keys and sign-in tokens are never included. See get help fast.

Try it: download Mail Attachment Downloader and start with the free edition, or compare the PRO editions, each with a 30-day money-back guarantee.

Related

Questions or suggestions about this post? Contact us.

Save emails and attachments to folders: PRO tips and tricks

PRO tips for saving emails and attachments to folders: how rules work, testing and tracing, multiple accounts, PDFs, databases and nested steps.

Saving emails and attachments to folders is easy with the PRO editions of Mail Attachment Downloader 4.0: PRO Backup, PRO Parser, PRO Rules Client and PRO Rules Server.

The PRO features page lists everything the program can do. This post picks out the tips people ask about most. Follow the links for the details.

PRO Rules and the parts of a rule

The key PRO idea is the rule. In 4.0, rules are in the PRO Rules tab (PRO Rules is the new name of 3.x’s Global filters). Tick Use PRO Rules for every account and the rules decide for all your accounts.

Rules run from the top down, for the email and for each attachment. When a rule takes one, it saves it, reads any values you asked for, then runs its steps. In the Rule Editor, each rule has these parts:

  • Which emails: the conditions that decide whether the rule runs.
  • Fields to find: values read from the email, cleaned up as needed.
  • Save: the attachments, the email or both, in a folder and file name that can use the values you read.
  • Then: the steps that run after saving, to automate the rest of the work.

More: PRO Rules overview and moving to PRO Rules, step by step.

Test and troubleshoot rules like a PRO

Rule not doing what you expected? Try these, in order:

  • Test this rule… in the Rule Editor, or Test all rules… in the PRO Rules tab. They show which rule saves each file, and nothing is moved, deleted or sent.
  • After a download, the Downloads tab shows which rule saved each file.
  • Rule settings › Check rule order… finds rules that a rule above them hides.
  • Rule tracing: in the PRO Rules tab, open Diagnostics, tick Rule tracing and download again. Then click Show the traces… to see, for each email and file, which rules matched and which condition didn’t. Tracing slows downloads, so turn it off when you are done.
The Rule trace viewer in its tree view: an Acme invoice email, the rules Acme invoices and Northwind statements not matched, and All PDFs matched and saving the file
Rule tracing: which rule matched each file of a real download, and which didn’t.

Still stuck? Search the knowledge base, or send us a bug report from the program.

Mail server connection tips

  • Set up your account: click Add account › Email account…, pick your provider, and the settings are filled in from your email address. See recommended settings.
  • Sign in with your browser for Gmail, Google Workspace, Outlook.com and Microsoft 365: no password is stored. See signing in with your browser. Yahoo, iCloud and others need an app password: the setup guide walks you through it.
  • Test Connection before you add rules or schedule downloads.
The account window for ap@contoso.example with Microsoft 365 picked and sign-in in the browser
Pick your provider, then click Test Connection to sign in.

Still having connection or sign-in problems?

  • A firewall, proxy or antivirus can block the connection or the sign-in. Open Connection diagnostics (in Settings › Logs and support): it shows each stage and warns when something inspects the traffic. Then check with your IT support.
  • See connection issues, and search the knowledge base for proxy settings and more.

License activation or moving a license

  • Activate: copy the fields from your license email exactly into the License tab and click Validate. No internet on that system? Use Activate offline….
  • Move to another system: enter your license there. If all its computers are in use, click Free a computer… and pick the one that no longer needs it.

See activate your license, or move it.

Running for multiple accounts

Pick <multiple@multiple> in the Account box, click Choose accounts…, tick the accounts and click Validate and use selected. PRO Backup runs up to 3 accounts together, PRO Parser up to 5, and PRO Rules Client and PRO Rules Server as many as you have. If one account fails, the others still run.

Choosing invoices@acme.example and purchases@acme.example to run together
Tick the accounts to run together, then Validate and use selected.

Read more: multiple email accounts with PRO Rules and download from several accounts at once.

PDF tips: save emails or attachments as PDF

Add Convert documents under Then to turn the email or its attachments into PDF (PRO Rules Client and up). PRO Rules Server converts to 50+ formats, such as multi-page TIFF and Word, and adds Convert all files to a single PDF, Merge PDFs, Split PDF and Make PDFs searchable (OCR).

The Rule Editor with a Merge PDFs step that joins the email's saved PDF files into one named by month
Merge PDFs joins an email’s saved PDFs into one file (PRO Rules Server).

Read more: save emails and attachments as PDF.

Extract data like the invoice number

The Parser tab (PRO Parser and up) reads values out of emails and their attachments. Highlight the invoice number in a sample, or describe it in words and let AI find it. Use it in the folder and file name, such as {SUPPLIER}\{INVOICE_NUMBER}_{FILENAME}{EXT}, or send it to CSV, Excel or Google Sheets.

The Parser with an Acme invoice sample and the invoice number, dates, total and supplier highlighted as fields
Highlight a value once, and the Parser finds it in the next emails.

For a quick field inside a rule, PRO Rules Client adds Find fields with AI. Read more: extract data from emails and attachments and PRO Parser.

Save extracted data to a database

With PRO Rules Server, Save to a database adds a row with the values you read to any ODBC database, such as SQL Server, MySQL or PostgreSQL. Store CSV / SQL loads the rows of Excel or CSV attachments.

A Save to a database step inserting the invoice number, supplier, date, total and saved file into dbo.Invoices
Save to a database: one row for each saved file.

Read more: save emails, files and invoice data to a database and the blog post.

Nest rules and steps like a PRO

Nest steps. Steps under Then run in order, and a step can hold steps that work on its result. For example, Unzip an attachment, then convert each file inside to PDF and save it to a database (PRO Rules Server).

Chain rules (PRO Rules Client and up). One shared filter picks the emails, and the rules under it each do one job with them. You write the condition once instead of repeating it in many rules. A rule can also start another with the Run another rule step.

The PRO Rules tab with a Supplier invoices filter and two rules under it: Upload to SharePoint and Save to the accounting database
A shared filter (1) with two rules under it (1.1 and 1.2).

Read more: chained rules and actions.

Try it: download Mail Attachment Downloader and start with the free edition, or compare the PRO editions, each with a 30-day money-back guarantee.

Related

Using version 3.x? See the 3.x version of this guide.

Filter features in PRO Rules: one account, rule order and catch-all rules

Email rule filters in PRO Rules: rules for every account or one, rule order and first match, catch-all rules, turning rules off and download dates.

PRO Rules let Mail Attachment Downloader handle each kind of email and attachment in its own way. This post answers the questions people ask most about them: which accounts a rule runs for, which rule wins, what happens when no rule matches, and which dates are downloaded. It is written for version 4.0.

New to rules? Start with the complete PRO Rules walkthrough: it shows how to make a rule, step by step.

What are PRO Rules?

PRO Rules are the rules you make in the PRO Rules tab, in PRO Rules Client and PRO Rules Server. In version 3.x this tab was called Global filters. Tick Use PRO Rules for every account at the top of the tab, and the rules decide what each account downloads.

The PRO Rules tab with a list of rules in the order they run; the last rule, Orders to the ERP, is switched off
The PRO Rules tab. Rules run in the order shown; the switch in the Enabled column turns a rule on or off.

Rules apply to every account

A rule runs for every account you download from. To download from several accounts in one run, pick <multiple@multiple> in the Account box and click Choose accounts…. Otherwise the download runs for the one account picked. See multiple email accounts with multiple rules.

When does a rule run?

For each attachment of an email, the program tries the rules from the top of the list down, to see whether one matches that file. When a rule saves the email itself (as an .eml file), the email goes through the rules too.

Make a rule apply to one account

Open the rule in the Rule Editor (select it and click Edit). Under Which emails, click Add a condition, pick Account and choose the account, for example finance@contoso.com. Click Save.

The rule now runs only for that account, and the list’s Account column shows it. To see only the rules of the account picked at the top, click Show only the rules for the picked account above the list. The rules for all accounts stay listed.

Rule order: the first match wins

Rules run from the top of the list down until one matches. The order matters:

  • Once a rule saves a file, no other rule runs for that file.
  • If the email has other attachments, each one starts again from the top.
  • Put narrow rules (Acme’s invoices) above broad ones (all PDFs).

To move a rule, drag it up or down. You can also select one or more rules and use Rule settings › Move in the list, or press Alt+Up and Alt+Down.

Not sure the order is right? Rule settings › Check rule order… finds rules that never save anything because a rule above them takes all their files, and offers to move them. Test all rules… on the same menu shows which rule saves each file of the emails you pick, without changing anything.

A catch-all rule for emails nothing saved

You made rules for the attachments you want. But what if none of them matched an email?

In 4.0 this is a rule type of its own. Make a new rule, click Save in its outline, and set Rule type: to Negative rule (steps for emails nothing saved). A negative rule saves nothing. Its steps run for the emails that no rule saved anything from. It runs after the other rules, wherever it sits in the list.

For example, tell the sender that their email didn’t have what you need:

  1. Give the negative rule a condition so it only answers the right people, for example From 'acme.example' OR 'northwind.example', or a Mailbox folder condition for your Invoices folder. Without one, it would answer every unmatched email, newsletters and spam included.
  2. Under Then, add a Send an email step. Put {EMAIL_FROM} in To: and write a short note, such as “We received your email ‘{SUBJECT}’, but it had no invoice attached.”
  3. Click Test this rule…, then Save.

Send an email needs PRO Rules Server. Steps that work on a saved file can’t be added to a negative rule, since it saves none. With PRO Rules Client, you can still use Move or copy the email to put those emails in a “Needs attention” folder.

A Send an email step in the Rule Editor, with Send from, To, a subject with the SUBJECT field and a text with the FROM field
The Send an email step (PRO Rules Server): fields such as {SUBJECT} are filled in for each email.
The Rule Editor on the rule No invoice attached: Rule type Negative rule (steps for emails nothing saved), and under Then a Send an email step to {EMAIL_FROM} and a move to Needs attention
A negative rule runs its steps for the emails no rule saved anything from.

Waiting for an email that never comes, such as a monthly statement? That is a different job: Expected emails notices when a rule’s regular email is late and runs steps when it is missing.

Turn rules on and off

Each rule has a switch in the Enabled column. Click it to turn the rule off, or right-click the rule and choose Turn off. For several rules at once, select them and use Rule settings › Disable entry or Enable entry.

A rule that is off never runs, and its settings are kept. Type “disabled” in the Search box to find the rules that are off, or use Hide disabled entries to leave them out of the list.

Download dates: the Search scope page

With PRO Rules on, the dates come from the PRO Rules tab, not from each account. Open its Search scope page:

  • Only emails from and Only emails up to apply to every account, and override each account’s own dates.
  • Each account decides (the default) lets each account keep its own choice of what it searches. The same for all accounts sets one choice for all of them: Messages since the last download or All mail.
The PRO Rules tab on Search scope: Each account decides, with three Contoso accounts and their Search in choice, and Date limits (every account) with Only emails from 1/1/2026
Search scope: what each account searches, and date limits for every account.

New in 4.0: each account has a History. It remembers the emails it has seen, so a download takes only the emails it hasn’t seen yet and nothing is downloaded twice. To bring in older emails later, or to process emails again, use Backfill emails….

Tip: before the first download of a large mailbox, set Only emails from, for example to the start of this year, so the first run doesn’t go through years of old mail.

Try it: download Mail Attachment Downloader and start with the free edition, or compare the PRO editions, each with a 30-day money-back guarantee.

Related

Using version 3.x? See the 3.x version of this guide.

Questions or suggestions about this post? Contact us.

Save emails and attachments to folders with PRO Rules: a complete walkthrough

A complete guide to saving emails and attachments to folders with PRO Rules: conditions, folders and file names, steps, rule order and testing.

This post shows how to save emails and attachments to folders with rules, step by step. It is the complete walkthrough of PRO Rules in Mail Attachment Downloader 4.0, the main reference that the other posts link to.

The Free edition saves each account’s attachments, emails or both into one folder, named one way. You set that on the account’s Account rule tab, on its Folders and file names page. The PRO Rules editions, PRO Rules Client and PRO Rules Server, go further: each kind of email can have its own folder, its own file names and its own steps after saving. PRO Rules Server can also run all of this 24×7 as a Windows service, on a PC, a server or a cloud VM, with nobody signed in.

The idea: one rule for each save location

To save different emails to different folders, make one rule for each folder. Each rule says:

  • which emails it takes (its conditions),
  • where it saves them and how the files are named,
  • what happens next (its steps).

For example: invoices from Acme go to \\fileserver\Finance\Invoices\Acme, purchase orders from Northwind go to \\fileserver\Finance\Orders, and scanned receipts are made searchable and uploaded to SharePoint.

PRO Rules: an overview

Rules live in the PRO Rules tab. In version 3.x this tab was called Global filters. Tick Use PRO Rules for every account at the top of the tab: from then on, the rules decide what each account downloads, instead of each account’s Search, Filters and Folders and file names pages. When you turn it on, the program offers to move your Account rules into PRO Rules, one rule per account, and shows you each rule first.

The PRO Rules tab with Use PRO Rules for every account ticked and a list of rules in the order they run
The PRO Rules tab: the rules, in the order they run, with a switch to turn each one on or off.

Rules run from the top of the list down, for each attachment, and for the email itself when a rule saves it. Each rule has five parts, which the Rule Editor shows top to bottom:

  • Which emails: the conditions that decide whether the rule runs. Otherwise the rule is skipped.
  • Fields to find: values read from the email, such as an order number, for the file names and the steps.
  • Save: what is saved, in which folder, and how the files are named. The folder and name can use the values found.
  • Then: the steps that run after saving, in order.
  • If something fails: the steps that run when a step above fails.

Rule tips and common questions

  • One account only: a new rule runs for every account. To keep a rule to one account, add an Account condition to it and pick the account, for example finance@contoso.com.
  • Several accounts in one run: pick <multiple@multiple> in the Account box, click Choose accounts… and tick the accounts. The rules run for each of them. See multiple email accounts with multiple rules.
  • First match wins: each file is saved by the first rule that matches it, and the rules below it never see that file. The next attachment of the same email starts again from the top, so it can go to another rule.
  • Change the order: drag a rule up or down, or select it and use Rule settings › Move in the list (or press Alt+Up and Alt+Down).
  • Similar rules: right-click a rule and choose Duplicate, then change the copy. If many rules share the same conditions, make a Shared filter with those conditions once and add the rules under it (right-click it › Add a rule under this shared filter). See chained rules and actions.

Name your rules well

With many rules, good names save time. Say a rule called “Invoices” runs for one account only, because it has an Account condition. Call it “finance@contoso.com – Invoices” instead. Then type finance@contoso.com in the Search box above the list to see only that account’s rules. The search also finds rules by kind, account and save folder.

Create a rule

Click New rule… in the PRO Rules tab. The Rule Editor opens. Type a name in Rule name: first. The left side shows the rule’s outline: click a part to change it on the right.

The Rule Editor for the rule Scanned invoices: the outline with Which emails, Fields to find, Save, Then and If something fails, and a Find fields with AI step on the right
The Rule Editor: the rule’s outline on the left, the selected part on the right.

Prefer plain words? Pick Create using AI… from the arrow next to New rule…: describe the rule, and the AI writes it for you to test before saving.

Which emails: the conditions

Click Which emails, then Add a condition. You can match on From, To, Subject, Body, Attachment name, Mailbox folder, Account, the received dates, the size, the number of attachments, Email security and more.

Say the rule should save invoices and payment advice. Add a Subject condition and type:

'Payments' OR 'Invoices'

  • OR: the rule runs when the subject has “Payments” or “Invoices” anywhere in it.
  • AND: all the words must be there, anywhere in the subject.
  • NOT: leaves emails out, for example 'Invoices' AND NOT 'reminder'.
  • = before a value matches only that whole value, and !! before a .NET regular expression uses the expression.

To combine conditions, put them in an Any of these group (OR) or an All of these group (AND). Click Test the expression… to try a condition on a sample text before you save. Conditions match the text as you type it: they don’t fill in fields such as {DATE}.

The conditions of a rule: a mailbox folder, received dates, an Account condition and an Any of these group with From and Subject
Conditions of a rule, with an Account condition and an “Any of these” group.

Fields to find: values from the email

A rule can read values out of the email, such as an order number, and keep them in a field in curly braces, such as {ORDER_ID}. Find them By pattern, By pointing at it in a sample, or With AI. The folder, the file name and the steps can then use them.

To read values from many similar emails or files, the Parser (PRO Parser and up) is the better way. More in extract data from emails and attachments.

Save: what, where and how it’s named

Click Save in the outline.

  • Rule type: leave it at Global rule (saves, then runs its steps) for a rule that saves files. The other types are for shared filters, shared actions and rules for emails nothing saved: see catch-all rules.
  • What to save: The attachments, The email and its attachments, The email only (an .eml file), or Nothing: back up only.
  • Save folder: for example \\fileserver\Finance\Invoices. Missing folders are made for you.
  • File name: a new rule starts with {FILENAME}_{ID}{EXT}. Click Fields… to add more fields, such as the sender or the date.
  • Only files of these types: keep only documents, pictures or the types you list, such as .pdf, .xlsx.

Important: with the Windows service (PRO Rules Server), use a network path such as \\fileserver\Finance in the save folder, not a mapped drive letter: the service can’t see mapped drives.

The Save part of a rule: Rule type, What to save, a save folder with a field for each sender, and a file name built from the date and the subject
The Save part: what is saved, where, and how the files are named, with an example below.

Folders and file names from fields

Fields fill in values from each email. Some examples:

  • \\fileserver\Finance\Invoices\{EMAIL_FROM} makes a folder for each sender’s address.
  • \\fileserver\Finance\FY2026-Q3\{ORDER_ID} makes a folder for each order number your rule found.
  • {DATE[yyyy-MM-dd]}_{FILENAME}_{ID}{EXT} puts the email’s date in front of each file name.

Keep {ID} in the file name. It is the message’s ID with the part number, so each file gets its own name, even when two emails both send invoice.pdf.

The full list of fields, with date formats and more examples, is in customizing file names and email data with fields.

Two more choices on the same page: Also save the email’s text and HTML parts saves the email’s text as .txt and .html files, and Leave out the pictures inside the text skips logos and signature images.

Then: steps after saving

After a file is saved, the rule can do much more. Click Add a step…, find the step by its group or by searching, and click Add. Steps run in order, and a step can hold steps that work on its result.

The Add a step window with the step groups Files, Email, Other systems, Data and fields, Notify, Decide and repeat and Programs, and the Files steps
Add a step: search, or browse the steps by group.

Some examples:

  • Archive the email: Move or copy the email to a folder on the mail server once its files are saved.
  • Invoice data: Add a row to a spreadsheet (Excel or Google Sheets) with the values found. See invoice processing.
  • Other systems: Upload to cloud (OneDrive, SharePoint, S3 and more) or Send to document management (Laserfiche, M-Files, DocuWare).
  • Databases: Save to a database, or Store CSV / SQL to load the rows of Excel or CSV attachments. See save emails and attachments to a database.
  • PDF and other formats: Convert documents to PDF, and with PRO Rules Server to 50+ formats such as multi-page TIFF, plus Merge PDFs, Split PDF and Make PDFs searchable (OCR).
  • Your own programs: Run a script or Run a command line on each saved file.
  • Tell someone: Send an email, Forward the email or Send notification (Slack, Teams and more) when a certain kind of email arrives.

PRO Rules Client converts to PDF only. Sending email, notifications, Unzip, OCR, Merge PDFs, Split PDF, databases, scripts, web hooks and AI prompts are PRO Rules Server steps. See all PRO features.

Test the rule before it runs

Click Test this rule… in the Rule Editor and pick some emails. Nothing is changed: files go to a temporary folder, and steps such as moving, deleting or sending are only described. Then click Save.

When you have several rules:

  • Rule settings › Test all rules… runs the rules that are on, in the list’s order, and shows which rule saves each file.
  • Rule settings › Check rule order… finds rules that never save anything because a rule above them takes their files, and offers to move them.
  • After a real download, the Downloads tab shows which rule saved each file.
  • Still puzzled? Open Diagnostics in the PRO Rules tab, tick Rule tracing and download again. Show the traces… then shows which condition matched and which didn’t. Turn it off when you are done: it slows downloads.
Test all rules: five sample emails from Acme, Northwind, Fabrikam and Contoso, each saved by 'Invoice PDFs' or 'All PDFs' or matched by no rule, with the details of the Northwind statement
Test all rules: which rule saves each email’s files, without changing anything.

Make a rule for each folder

Repeat this for each kind of email: one rule per save location, each with its own conditions, folder, file name and steps. Then click Connect and Download, or schedule it on the Schedule tab.

Running the Windows service? It keeps the copy of your rules it got when it was installed. After you change a rule, open Schedule › Service schedule and click Reinstall…. See the PRO Rules Server how-to.

New in 4.0: each account has a History. It remembers the emails it has seen, so nothing is downloaded twice, and a step that failed is tried again on its own.

Uses and scenarios

Many businesses use “magic folders”: a scanning, capture, OCR, invoice processing or document management product watches a folder and picks up each new file. PRO Rules feed those folders from email, one folder per kind of document, with the names those products expect. Where 4.0 has a direct connector, such as Upload to cloud, Send to document management or a database step, you can skip the folder and send the file straight there.

Try it: download Mail Attachment Downloader and start with the free edition, or compare the PRO editions, each with a 30-day money-back guarantee.

Related

Using version 3.x? See the 3.x version of this guide.

Questions or suggestions about this post? Contact us.

Save CSV and Excel attachments to a database

Load the rows of CSV and Excel files you receive by email into SQL Server, MySQL or any ODBC database automatically.

Do you get sales reports, price lists or order exports by email as CSV or Excel files? Mail Attachment Downloader can put their rows straight into a database table, each time a new file arrives.

If the files don’t come by email yet, you can email them to a mailbox of your choice, from anywhere, and let the program pick them up.

Version 4.0 has two ways to do it:

  • The Store CSV / SQL step in a rule: you map each column of the file to a field, and write the SQL. It needs PRO Rules Server.
  • The Parser: it finds the table for you, checks it, and writes the lines to a database. More on it below.

Before you start: a data source

The program talks to your database through ODBC: SQL Server, MySQL, PostgreSQL, Oracle, Access and others. Set up a data source once in Settings › Sources › Data Sources. Version 4.0 is 64-bit, so it needs your database’s 64-bit ODBC driver. The steps are in Save emails and attachments to a database.

Then make the table the rows go into, for example dbo.SalesLines with the columns Description, Price and Quantity.

Step 1: A rule for the emails with the files

  1. Open the PRO Rules tab. Click New rule…, or select a rule and click Edit.
  2. Under Which emails, add the conditions, for example From ‘fabrikam.example’ and Subject ‘daily sales’.
  3. Under Save, set What to save to The attachments and pick the Save folder, for example \\fileserver\Finance\Sales. Under Only files of these types, type .csv, .xlsx, .xls in Other:.

Step 2: Add a Store CSV / SQL step

  1. Click Add a step…, choose Data and fields, then Store CSV / SQL, and click Add.
  2. In Data source:, pick your data source. In Table:, pick the table, or type its name.

Step 3: Map the columns to fields

Under The file’s columns:

  1. Next to Sample file:, click Browse… and pick a CSV or Excel file like the ones you receive.
  2. Pick the Sheet: to read. A CSV file has one.
  3. If the file starts with a row of column titles, tick The first row has the column names.
  4. Click Read the columns. The columns are listed by name (or by cell, such as A1 and B1, when there are no titles).
  5. Tick Use for each column you want, and type the Field it goes into, in braces (the braces are needed): {DESCRIPTION}, {PRICE}, {QUANTITY}.

Need only part of a cell? Click Pattern… next to the column. Does the table start lower down or further right in the sheet? Set Start row: and Start column: under More options.

Step 4: Write the SQL and test it

In SQL:, write the statement that adds one row. It runs once for each row of the file:

INSERT INTO {TABLE_NAME} (Description, Price, Quantity) VALUES ({DESCRIPTION}, {PRICE}, {QUANTITY})

Each field goes into the SQL as a value, so it needs no quotes. {TABLE_NAME} is the table you picked. Click Fields… to add the email’s own fields as well, such as {EMAIL_FROM}.

Click Test with the sample file. It asks first, then inserts the sample file’s rows into the table. Check the table in your database, then click Save.

The Rule Editor with a Store CSV / SQL step: data source, table dbo.InvoiceLines, the sample file and sheet, The first row has the column names ticked, and four columns each with a field
A Store CSV / SQL step: the table, the sheet, and the field each column goes into.

That’s it. From now on, the rows of each matching file are added to the table. The Downloads tab shows each email and whether the step worked. Each email is handled once: its History keeps the same file from being loaded twice.

Keep in mind that the step only adds rows. If you Redo an email, its rows are added again.

The Parser way: let it find the table

The Parser, new in 4.0, reads tables from Excel and CSV files, and from PDFs and HTML emails too. You don’t map cells or write SQL:

  1. On the Parser tab, click New parser and pick a few of the report emails as samples.
  2. Under Fields, the Parser finds the table and its columns, and shows the rows it read in each sample. You can also Describe the rows in words.
  3. Under Output, send the lines to a database, an Excel workbook or Google Sheets, one row per line.
The Parser's Fields step: a table of description, quantity, unit and amount read from three supplier samples, with a check that the rows add up to the subtotal
The Parser reads the table of each sample, and checks that the rows add up.

Why use it:

  • Processing an email again replaces its lines instead of adding them twice.
  • It can check that the lines add up to the total, and hold a doubtful file for you to approve.
  • It finds the table by its header row, and reads it from a PDF or an HTML email as well.

The Parser comes with PRO Parser, which writes to CSV, Excel and Google Sheets. Its SQL database output, and saving the lines to a database, need PRO Rules Server. See PRO Parser.

Use Store CSV / SQL when the files are clean tables with fixed columns and you want your own SQL. Use the Parser when the layouts vary or you want checks.

Try it: download Mail Attachment Downloader and start with the free edition, or compare the PRO editions, each with a 30-day money-back guarantee.

Related

Using version 3.x? See the 3.x version of this guide.

Contact us with any questions or suggestions about this post.

Download from multiple email accounts with multiple rules

Download from several email accounts in one run and give each kind of email its own folder, file name and steps with PRO Rules.

The Free edition of Mail Attachment Downloader downloads from one email account per run. Each account has one rule: the Account rule tab says which emails it downloads, which files it keeps and where it saves them.

This post shows how the PRO editions go further: several accounts in one run, and many rules, each with its own folder, file names and follow-up steps. It is written for version 4.0.

The Account rule tab of the Free edition, on its Filters page, for the account ap@contoso.example
Free edition: one Account rule per account, with its Search, Filters and Folders and file names pages.

Multiple email accounts

In the Free edition you pick an account in the Account box and click Connect and Download. To download from another account, you pick it and run again.

In the PRO editions one run can take several accounts:

  1. Add each account on its own first, with Add account › Email account…, and check it with Test Connection.
  2. Pick <multiple@multiple> in the Account box. The Settings… button next to it changes to Choose accounts….
  3. Click Choose accounts…, tick the accounts, for example finance@contoso.com and ap@contoso.com, and click Validate and use selected. Each account is checked: it must sign in, and its save folders must be writable. Every problem is listed at once.
  4. Click Connect and Download. The accounts run one after another. If one fails, for example because its sign-in expired, the others still run.
The Select accounts window with two accounts ticked and the Validate and use selected button
Tick the accounts, then click “Validate and use selected”.

How many accounts run together depends on the edition: PRO Backup up to 3, PRO Parser up to 5, and PRO Rules Client and PRO Rules Server as many as you have. See the plans and prices.

<multiple@multiple> has no settings of its own. Each account downloads with its own settings. To change them, pick that account in the Account box.

After the run, the Downloads tab shows what each account did: the emails, the files, any errors, and which rule saved each file. Each run names its account. An account that can’t run until you fix something is listed under Action required.

New in 4.0: each account has a History. It remembers the emails it has seen, so nothing is downloaded twice, and a step that failed is tried again on its own.

Several accounts in the background

With PRO Rules Server the program can run as a Windows service, on a PC, a server or a cloud VM, even when nobody is signed in. Open Schedule › Service schedule, pick <multiple@multiple> in Install the service for, click Select accounts…, tick the accounts and click Validate and use selected. Then click Install service.

The Service schedule page of the Schedule tab, with the Install the service for box and the Install service button
Schedule › Service schedule: choose the accounts, then install the service.

The service keeps the copy of your settings it got when it was installed. When you change a setting or a rule later, the page shows Reinstall to apply changes: click Reinstall…. See the PRO Rules Server how-to.

Multiple email rules

The Account rule gives each account one set of choices. For example, on the Search page you set a start date, and on the Filters page you keep only emails whose subject has “invoice”. All of that account’s matching files go to one folder, named one way.

But what if invoices from Acme should go to one folder, purchase orders from Northwind to another, and Word files should also be turned into PDFs?

That is what PRO Rules are for (PRO Rules Client and PRO Rules Server). In version 3.x this tab was called Global filters. Each rule has its own conditions, its own save folder and file names, and its own steps that run after saving.

The PRO Rules tab with Use PRO Rules for every account ticked and a list of rules in the order they run
The PRO Rules tab: the rules, in the order they run.

How PRO Rules work

  • Turn them on: tick Use PRO Rules for every account at the top of the PRO Rules tab. The rules then decide what each account downloads, instead of each account’s Search, Filters and Folders and file names pages.
  • Dates: on the Search scope page of the PRO Rules tab, Only emails from and Only emails up to apply to every account, and override each account’s own dates. On the same page, choose whether Each account decides what it searches (new mail or all mail) or it is The same for all accounts.
  • Every account, or one: a new rule is for all accounts. To make a rule for one account only, add an Account condition to it (more below).
  • Order matters: rules run from the top of the list. Each file is saved by the first rule that matches it, so the rules below it never see that file. The next file of the same email starts again from the top. Drag a rule up or down to change the order.
  • Moving from Account rules: when you turn PRO Rules on, the program offers to move your Account rules to PRO Rules too. Each account’s Search, Filters and folder settings become a rule of its own, and you see each rule first.

Make your first rule

Click New rule… in the PRO Rules tab. The Rule Editor opens. Give the rule a name in Rule name:, for example “Acme invoices 2026 Q1”. The rule has these parts, top to bottom: Which emails, Fields to find, Save, Then and If something fails.

Which emails: the conditions

Click Add a condition and pick what to match: From, Subject, Attachment name, Mailbox folder, Received on or after, Account and more. Put several conditions in an Any of these or All of these group to combine them with OR or AND.

To match on the subject, add a Subject condition and type what to look for:

  • Text in quotes: 'invoice' matches any subject that has “invoice” anywhere in it.
  • AND, OR and NOT: ('invoice' OR 'bill') AND NOT 'reminder'. Use parentheses to group them.
  • A whole value: = before a value matches only that exact text.
  • A regular expression: !! before a .NET regular expression.

Click Test the expression… to try it on a sample text before you save. Conditions match the text exactly as you type it: they don’t fill in fields such as {DATE}.

The Test an expression window: the expression 'invoice' OR 'bill' tried on a sample sentence, with the result It matches
“Test the expression…” shows whether a condition matches.

One account only: add an Account condition and choose the account, for example finance@contoso.com. Without it, the rule runs for every account.

The Rule Editor with conditions for a mailbox folder, received dates, an account, and an Any of these group with From and Subject
Conditions of a rule, with an Account condition and an “Any of these” group.

Save: what, where and how it’s named

Click Save in the rule’s outline:

  • What to save: The attachments, The email and its attachments, or The email only (as an .eml file). Emails without attachments are saved too when the email is part of what you save.
  • Save folder: for example \\fileserver\Finance\Invoices. For a network folder, use a \\server\share path, not a mapped drive letter: the Windows service can’t see mapped drives.
  • File name: build it from fields. Click Fields… to pick them. For example {DATE_LOCAL[yyyy-MM-dd]}_{FILENAME}_{ID}{EXT}.
  • Only files of these types: keep only documents, pictures or the types you list, such as .pdf, .xlsx.

A field in the save folder makes a folder for each value. For example, \\fileserver\Finance\Invoices\{EMAIL_FROM} makes a folder for each sender’s address. Missing folders are made for you.

Keep {ID} in the file name. It is the message’s ID with the part number, so each file’s name is different, even when two emails send a file called invoice.pdf.

The Save part of a rule: What to save, Save folder, File name with fields, and Only files of these types
The Save part: what is saved, where, and how the files are named.

Fields to find: values from the email

A rule can also read values, such as an invoice number, and use them in folder names, file names and steps. For values you read from many similar emails, the Parser (PRO Parser and up) is the better way: highlight the value in a sample, or describe it in plain words. A parser is saved as a PRO rule, so you can add your own steps after it.

Then: steps after saving

Steps run after the file is saved, in order. Click Add a step…, find the step and click Add.

Say Acme sends Word documents and you want PDFs. Add the Convert documents step, click Add… and choose the conversion. Tick Delete the originals after converting them if you only want the PDFs.

The Convert documents step in the Then part of a rule, with the Add, Edit and Remove buttons
A Convert documents step under “Then”.

Other steps move or delete the email on the server, upload to the cloud, add a spreadsheet row and much more. Some steps need PRO Rules Server: PRO Rules Client converts to PDF only, and sending email, unzipping, databases and scripts are Server steps. See chained rules and actions.

Test and save the rule

Click Test this rule… to try it on emails you pick. Nothing is changed: files go to a temporary folder, and steps such as moving, deleting or sending are not done. Then click Save. That’s your first rule.

Make as many rules as you need, each with its own conditions, folders and steps. Before the first real run, use Rule settings › Test all rules… to see which rule saves each file, and Check rule order… to find rules that never save anything because a rule above them takes their files.

Points to remember

  • Rules run for each attachment, and for the email itself when a rule saves it.
  • A rule without an Account condition runs for every account.
  • Rules run from the top down. The first rule that matches a file saves it, and the rules below don’t see that file.
  • Steps under Then run after a file is saved. Steps under If something fails run when a step above fails.
  • Using the service? After changing a rule, click Reinstall… on Schedule › Service schedule.
  • Don’t want to build a rule by hand? Describe it to the AI Assistant and it writes the rule for you to check.

Try it: download Mail Attachment Downloader and start with the free edition, or compare the PRO editions, each with a 30-day money-back guarantee.

Related

Questions or suggestions about this post? Contact us.