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
- Open the PRO Rules tab. Click New rule…, or select a rule and click Edit.
- Under Which emails, add the conditions, for example From ‘fabrikam.example’ and Subject ‘daily sales’.
- 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, .xlsin Other:.
Step 2: Add a Store CSV / SQL step
- Click Add a step…, choose Data and fields, then Store CSV / SQL, and click Add.
- 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:
- Next to Sample file:, click Browse… and pick a CSV or Excel file like the ones you receive.
- Pick the Sheet: to read. A CSV file has one.
- If the file starts with a row of column titles, tick The first row has the column names.
- Click Read the columns. The columns are listed by name (or by cell, such as A1 and B1, when there are no titles).
- 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.

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:
- On the Parser tab, click New parser and pick a few of the report emails as samples.
- 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.
- Under Output, send the lines to a database, an Excel workbook or Google Sheets, one row per line.

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
- Save emails and attachments to a database
- Read Excel and CSV attachments
- Parser output: CSV, Excel, Google Sheets, a database and more
- Save emails, files and invoice data to a database
- Emails to CSV and Excel
- Extract data from emails and attachments
- Save emails and attachments to folders with PRO Rules
- Plans and prices
Using version 3.x? See the 3.x version of this guide.
Contact us with any questions or suggestions about this post.