Save email data to Excel or Google Sheets: one row per email or invoice line

Save email data to Excel or Google Sheets automatically: one row per email or invoice line, read from emails and attachments, never added twice.

To save email data to Excel or Google Sheets, a program has to read the values out of each email and add them as a row. Mail Attachment Downloader does both: its Parser reads the invoice number, the supplier, the total or any other value from the email and its attachments, and adds one row per email, or one per invoice line, to an Excel workbook or a Google Sheet. Process the same email again and its row is replaced, never added twice.

The examples use Contoso’s mailbox finance@contoso.com, the workbook \\fileserver\Finance\Invoices.xlsx, and invoices from Acme, Northwind and Fabrikam, such as INV-2026-0412.

Three ways to get email attachments into a spreadsheet

  • The Parser’s outputs: the easiest. You show the Parser which values to read, then turn on Excel workbook or Google Sheets. The lines of an invoice table can get a tab of their own.
  • The rule step Add a row to a spreadsheet: a row for each email a PRO rule picks, with any fields the rule has: the sender, the subject, the date, or values its steps found.
  • Save metadata: a CSV file of the email’s details for each saved file, which Excel opens. The simplest log.

What you need

Parse email to Excel with the Parser

  1. On the Parser tab, click New parser and add a few sample emails, such as one invoice each from Acme, Northwind and Fabrikam.
  2. In the Fields step, mark the values: highlight the invoice number in a sample, or describe it in plain words and let the AI find it. See Extract data from email with AI.
  3. In the Output step, choose One record for each: email, or attachment named (such as order_*.pdf) for a row per attachment.
  4. Turn on Excel workbook. Enter the Workbook (.xlsx), such as \\fileserver\Finance\Invoices.xlsx, and the Sheet (empty: the parser’s name).
  5. Under Columns, give each column a Heading and a Value (fields in braces), such as “Invoice number” and {INVOICE_NUMBER}. Fields… picks one, and Every field, as at first puts back one column per field.

The CSV file, the Excel workbook and the Google Sheet share one Columns list, so they hold the same columns. The preview on the right shows the row of the sample you’re on.

Parse email to Excel or CSV: the Output step of the Parser for Supplier invoices, one record for each email, the Columns list Invoice number, Invoice date, PO number, Due date, Total and Supplier with fields in braces, a CSV preview of sample INV-2026-0412, and Run it again and nothing doubles
The Output step: one Columns list for the CSV file, the Excel workbook and the Google Sheet.

Before you turn it on, click Test on the card, then Try the write on a temporary copy: it writes into a copy of the workbook, shows it, and deletes the copy. Your workbook is only read.

The Parser's Output step for Supplier invoices: the Excel workbook card on, writing to \\fileserver\Finance\Invoices.xlsx with four columns and the table lines on their own tab, and the Google Sheets card on with the Finance Google Drive connection, with a preview of each row on the right
The Parser’s Output step: the same row to an Excel workbook and a Google Sheet, and the invoice lines on a tab of their own.

Save email to Google Sheets

Google Sheets is reached through a Google Drive connection you make once with your own Google Cloud app:

  1. In the Google Cloud project of that app, enable the Google Sheets API as well as the Google Drive API.
  2. Add the connection in Settings › Sources › Cloud Connections. Save email attachments to SharePoint, OneDrive, S3 or Google Drive shows how.
  3. In the Google Sheet, add the tab the rows go to.
  4. In the Parser’s Output step, turn on Google Sheets, pick the Google connection, paste the Address of the Google Sheet from the browser, and enter the Tab.

The values leave your computer for Google, so the Parser asks first and names where they go. Its Test, Write one test row…, writes to a tab called PARSER TEST, shows it and removes it again. Values go in as plain values: a text that starts with = is never run as a formula.

One row per invoice line

Many invoices are a table of lines. When the parser reads a table, the Excel workbook and Google Sheets cards offer Also write the table lines. The lines go to a tab of their own, one row per line, the email’s key first, so a lookup joins them to the email’s row. Under Repeat on each line, choose The email’s key only, Every field the parser reads (the supplier and the invoice number on each line, ready for a pivot table), or Choose fields….

Email invoice lines to a spreadsheet: the Parser's table lines with columns description, qty, unit and amount read from INV-2026-0412.txt, adding up to the subtotal 416.50, written as one row for each line
A table of invoice lines: written as one row for each line.

Run it again and nothing doubles

Each row starts with the email’s key (its account and message), kept in the first column. When the same email is processed again, after you correct a value in Needs you or with Process again…, its row is replaced, and its invoice lines are replaced where they were. Other emails’ rows are not touched.

A value is a number only when it is plain digits, so an invoice number like 00123 keeps its zeros.

Add a row to a spreadsheet in a PRO Rule

With PRO Rules Client or PRO Rules Server, any rule can add a row:

  1. On the PRO Rules tab, click New rule… or Edit, and set Which emails, such as the sender’s domain acme.example.
  2. Under Then, click Add a step…, open Data and fields and double-click Add a row to a spreadsheet.
  3. In Where the rows go, choose An Excel workbook (.xlsx) or A Google Sheet.
  4. Enter the Workbook file, or address of the Google Sheet, and the Sheet or tab (Parsed to begin with). A Google Sheet also needs its Google connection.
  5. Under Columns, click Add a column for each one: a heading and a value such as {FROM}, {SUBJECT}, {DATE} or {TOTAL}.

The step adds one row for each email, after the email is processed. For values from inside the attachments, put Find fields with AI or Find fields in the file before it.

Email attachments to spreadsheet: the Add a step window with Data and fields chosen, showing Find fields in the file, Find fields with AI, Look up from a database, Save to a database, Store CSV / SQL, Save metadata, Fill a template, Run an AI prompt and Add a row to a spreadsheet
Add a step › Data and fields › Add a row to a spreadsheet.
Mail Attachment Downloader's Add a row to a spreadsheet step: rows go to the Excel workbook \\fileserver\Finance\Invoices.xlsx, sheet Invoices, with the columns From, Subject, Received and Total from the email's fields, once per email
Add a row to a spreadsheet: one row per email, replaced if the same email comes again.

The simplest log: Save metadata to a CSV file

If you only need who sent what and when, the Save metadata step adds a line for each saved file to a CSV file, with the email’s details: the file’s name, the sender, the recipients, the subject and the date to begin with. Tick Add to the file when it is there (otherwise replace it) to keep one running log, and open it in Excel.

The Save metadata step in the Rule Editor for Supplier invoices: a CSV file in the save folder with the columns file name, original file name, from, to, CC, subject and date, Add to the file when it is there ticked, Run For each saved file
Save metadata: a CSV line for each saved file.

The other way round: Excel attachments into a database

Receive a daily sales report as an Excel or CSV attachment? With PRO Rules Server, the Store CSV / SQL step reads its rows and adds them to a database table. See Save CSV and Excel attachments to a database.

The Store CSV / SQL step for Fabrikam daily sales: data source Contoso Finance, table dbo.SalesLines, an INSERT statement, and the columns Description, Price and Quantity read from the sheet Daily sales of an .xlsx sample file
Store CSV / SQL: the rows of an Excel attachment into a table.

Questions people ask

Can I save each email to Google Sheets automatically?

Yes. Each email the parser or rule picks adds a row as it is downloaded, on the program’s schedule or as soon as new email arrives.

Does Excel have to be installed?

No. The program writes the .xlsx file itself. Keep the workbook closed in Excel while downloads run: a workbook that is open can’t be replaced, and the step fails until it is closed.

Can I get one row per attachment instead of per email?

Yes, in the Parser: set One record for each to attachment named, such as order_*.pdf.

What leaves my computer?

Nothing for an Excel workbook or a CSV file. For a Google Sheet, the values in the row go to Google, through your own Google app.

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 about this post? Contact us.

Process e-invoices from email: ZUGFeRD, Factur-X, XRechnung and Peppol UBL

Turn ZUGFeRD, Factur-X, XRechnung and Peppol UBL invoices from email into CSV, Excel or SQL rows, with sum and duplicate checks. No AI needed.

More and more invoices arrive as e-invoices: a PDF with the invoice’s data inside it, or the data alone as an XML file. That data already holds the invoice number, the dates, the supplier, the totals and every line. You shouldn’t have to type it in again, or ask an AI to guess it from the picture.

This post shows how Mail Attachment Downloader’s PRO Parser picks e-invoices out of a mailbox, reads their own data, checks it, and writes it to CSV, Excel or a database, with each invoice file saved under a name that means something.

Why e-invoices are arriving now

Several European countries are making structured e-invoices the norm between businesses. In Germany, businesses have had to be able to receive e-invoices since January 2025, and the duty to send them phases in through 2028. France’s reform began in September 2026, also in phases, and many other countries exchange e-invoices over the Peppol network.

Dates and details change, and they depend on your country and your business. Check the rules that apply to you; this post is not legal or tax advice.

What the Parser reads

The Parser reads the invoice’s own data. It finds it in two places:

  • A PDF with the XML inside it. Factur-X and ZUGFeRD invoices are PDF/A-3 files that carry the XML as an embedded file. You see a normal invoice; the Parser reads the data.
  • The XML alone. An XRechnung or a Peppol invoice is often just an XML file attached to the email. The Parser knows it by what it holds, not by its name.

It reads the two forms that EN 16931, the European e-invoice standard, allows:

  • CII: the UN/CEFACT Cross Industry Invoice, used by Factur-X, ZUGFeRD 2 and XRechnung in its CII form.
  • UBL 2.1: used by XRechnung in its UBL form and by Peppol BIS Billing 3.

Credit notes are read too. The older ZUGFeRD 1.0 is not.

The example

Contoso’s accounts payable team gets invoices at finance@contoso.com. Acme sends Factur-X PDFs, Fabrikam sends XRechnung XML files, and Northwind’s invoices come in as Peppol UBL. We want each one in a spreadsheet, and each invoice file saved in \\fileserver\Finance under its supplier and invoice number.

Step 1: Show the Parser an e-invoice

Open the Parser tab and click “New parser”. In “Source”, choose “Emails from a mailbox” and search for an email with an e-invoice, such as “INV-2026-0423”. Or choose “A file”, or drop the PDF or XML on “Drop files or emails here”.

The Parser's Source step: emails found by searching INV-2026-0423, the email from Acme Beispiel GmbH ticked as a sample and 1 email pinned
Pick an e-invoice email from Acme as the sample.

The step suggests 3 to 25 samples of the same kind. For e-invoices one already gives every field, because the values come from the invoice’s own data, not from learning; a few more let you check the results on several suppliers.

Step 2: Use the invoice’s own data

In “Fields”, when the sample carries e-invoice data, a green banner says so: “This invoice carries its own data. 22 fields and 2 lines found, exact, no AI needed.”

The Fields step of a new parser showing a Factur-X XML invoice, with a green banner: This invoice carries its own data, 22 fields and 2 lines found, exact, no AI needed, and the buttons Use the invoice's data and Choose which
The Parser sees that the sample carries its own invoice data and offers to use it.

Click “Use the invoice’s data”. Each value becomes a field, and the lines become a table. Or click “Choose which…” to tick only the values you want, then “Use the chosen”.

The fields you can get are: invoice number, invoice date, due date, currency; seller and buyer name, VAT id, country and email; buyer reference, order number, payment means, IBAN; subtotal, tax total, total, amount due; the document type (invoice or credit note) and the sum of the lines. An invoice only gives the values it holds.

The lines table has a row for each line of the invoice: line number, description, quantity, unit, unit price, tax rate and amount. Simpler e-invoices may carry no lines; then you get the fields alone.

The Fields step after Use the invoice's data: 22 fields such as invoice_number, issue_date, due_date, currency, seller_name and seller_vat_id, each tagged From invoice data and found in 1 of 1 samples, a lines table, and the values highlighted in the XML
22 fields and the lines, made from the invoice’s own data. Each field is tagged “From invoice data”, and its value is highlighted in the XML.

These fields are tagged “From invoice data”. No pattern to keep up, no AI to pay for, and the values are exact: dates as yyyy-MM-dd, amounts with a dot. Nothing leaves your system. Tick “Show fields” to see where each value sits in the XML.

Step 3: Check what came in

Exact values can still be wrong for you: a total far bigger than usual, lines that don’t add up, or the same invoice sent twice. In “Checks”:

  • Per field. Under “Check each field”, give the total a range with “Between”, or mark a field “Not blank”. Under “If it fails”, choose “Send to review”.
  • Sums. Under “Check fields together”, tick “The amounts of the lines add up to the subtotal (within 0.01)”. For an e-invoice, the lines are checked against the sum the invoice itself states.
  • Duplicates. Tick “The same”, pick the invoice number and the supplier (for e-invoices, invoice_number + seller_name, or the seller’s VAT id), and choose what happens when it “was parsed before:” “Skip it and note it”, or send it to review. A supplier who sends the same invoice twice isn’t paid twice.
The Checks step: a Between 0.01 and 100000 check on the total that sends it to review, the lines add up and subtotal plus tax checks, a duplicate check on invoice_number + supplier set to Skip it and note it, and the review queue settings, with 3 samples passing
Checks on a supplier-invoice parser: a range for the total, sum checks, and the duplicate-invoice check, tried on the samples first.

Under “Send an email to the review queue when”, leave “Any check above fails” and “A required field is blank” ticked.

Step 4: Review what was held back

An invoice that fails a check waits in Parser › “Needs you”. Nothing is written, sent or moved for it until someone looks. You see the email beside its values; fix one if needed and click “Approve and run the actions (Alt+A)”, or “Skip for now (Alt+S)”, or “Reject: do not process (Alt+R)”.

The Needs you queue of a parser called Supplier invoices: one invoice waiting, shown beside its values, with the buttons Approve and run the actions, Skip for now and Reject
The review queue. This one is a plain text invoice held for a low-confidence read; an e-invoice is held when a check fails or it is a duplicate.

Step 5: Send the data where you need it

In “Output”, choose where the values go. With PRO Parser:

  • “CSV file”, “Excel workbook” or “Google Sheets”: one row per email, with the columns you pick, such as {INVOICE_NUMBER}, {SELLER_NAME}, {ISSUE_DATE} and {TOTAL}. The invoice lines can go to their own sheet, one row per line.

With PRO Rules Server:

  • “SQL database”: a row per invoice in SQL Server, MySQL, PostgreSQL or any ODBC database.
  • “Webhook”: the fields as JSON to your accounting or ERP system.
  • “Tell me”: a message to Slack, Teams and other channels.

Each output has a “Test” button. Processing the same email again replaces its row instead of adding a second one.

Step 6: Save and name the invoice file

Under “Save files”, choose “The attachments” for the PDF or XML, or “The email and its attachments” to keep the email as an .eml file as well. Then build the folder and name from the fields with “Fields…”:

Folder: \\fileserver\Finance\E-invoices\{SELLER_NAME}
File name: {ISSUE_DATE}_{INVOICE_NUMBER}_{FILENAME}{EXT}

Acme’s invoice then lands as \\fileserver\Finance\E-invoices\Acme Beispiel GmbH\2026-10-22_INV-2026-0423_INV-2026-0423.pdf. The PDF is saved as it arrived, with its embedded XML.

The Output step: Save files set to The attachments, with folder and file name boxes and Fields buttons, and a CSV file with columns for invoice number, invoice date, PO number, due date, total and supplier, with a CSV preview
Save files and a CSV file on the Output step. The folder and name take any field the parser reads.
The Parser's Output step for the E-invoices parser: The attachments saved to \\fileserver\Finance\E-invoices\{SELLER_NAME} as {ISSUE_DATE}_{INVOICE_NUMBER}_{FILENAME}{EXT}, the For example path, and a CSV preview of the 22 values
Save each e-invoice in a folder per supplier, named by date and invoice number.

Step 7: Turn it on

In “Run on”, choose the accounts. Tick “Process the emails in the backup now” to handle the e-invoices of the last 30 days straight away, without downloading them again. Leave “Turn on after saving” ticked and save. From then on, the parser runs with each download.

Suppliers who send plain PDFs need a second parser, built with “Highlight” or “Using AI”; see invoice emails to your invoice processing software.

What it doesn’t do

  • It reads e-invoices; it doesn’t create or send them.
  • It doesn’t validate an invoice against the official XRechnung or Peppol rules. It takes the totals as the invoice states them and checks only what you set up in “Checks”.
  • It reads e-invoices that arrive by email (or as files). It isn’t a Peppol access point. If your Peppol provider can pass invoices on by email, the Parser reads them like any other.

Which edition do you need?

  • PRO Parser: everything above with CSV, Excel and Google Sheets output, up to 5 accounts per run. Includes PRO Backup.
  • PRO Rules Server: adds the SQL database, webhook and “Tell me” outputs, and runs as a Windows service with no one signed in.

The Free edition can save e-invoice files but doesn’t read their data. See PRO Parser: e-invoices and pricing.

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

Contact us with any questions about this post.

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.

Save emails and attachments to a database (SQL Server and any ODBC database)

Add a row to SQL Server, MySQL, PostgreSQL, Oracle or any ODBC database for each email or attachment, with an ODBC data source and one rule step.

In this post we save emails and attachments to a database server such as SQL Server. You set up an ODBC data source once, then add a Save to a database step to a rule. Each time the rule saves a file, a row goes into your table.

The program works with any database that has a 64-bit ODBC driver: SQL Server, MySQL, PostgreSQL, Oracle, Access and more. This post uses SQL Server, with notes for other databases. It is written for version 4.0.

An overview: emails to databases

Database steps are part of PRO Rules Server.

  • You don’t need to know SQL. Create table makes a table and writes the SQL for you.
  • If you do know SQL, you can change the statement to suit your own tables.
  • Put any field in the SQL: the sender, the subject, the date, where the file was saved, and values read from the email or its files, such as an invoice number.

A rule works in steps. First its conditions pick the emails or files. Then it can read values from them. Then it saves the files to a folder. Last, its steps run, and Save to a database is one of them.

It runs on your own system and talks to your database directly through ODBC. As a Windows service it runs around the clock, on a PC, a server or a cloud VM, even when nobody is signed in.

Step by step: emails to a database

1. Set up a data source

Open the Settings tab, go to Sources, choose Data Sources and click Add…. The Data source configuration window opens.

  1. Give the source a name in Name:, for example “Contoso Finance”.
  2. Pick the driver in Choose driver:. Version 4.0 is 64-bit, so it lists the 64-bit ODBC drivers installed on this computer. For SQL Server, pick a SQL Server driver.
  3. Type the Connection string:. For SQL Server with Windows sign-in it looks like this:
    Server=<computer name>\<SQL Server instance>;Database=<database name>;Trusted_Connection=yes;

For example:

Server=CONTOSO-SQL01\FINANCE;Database=ContosoInvoices;Trusted_Connection=yes;

Click Test connection. Once it says Connection succeeded., click OK. The data source is ready.

Settings, Sources, Data Sources with the Data source configuration window: name Contoso Finance, ODBC Driver 18 for SQL Server (64-bit ODBC), the Contoso connection string and Connection succeeded
A data source for the database steps: name, 64-bit ODBC driver and connection string, tested.

To connect another way, or to another database such as Oracle or MySQL, look up its ODBC connection string, for example on connectionstrings.com. Choose the ODBC string, not the other kinds.

2. Add a Save to a database step to a rule

Open the PRO Rules tab. Click New rule…, or select a rule and click Edit. The Rule Editor opens.

  1. Set the rule’s conditions under Which emails, for example From ‘acme.example’ and Attachment name ending in .pdf, and where the files are saved under Save, for example \\fileserver\Finance\Invoices.
  2. Click Add a step…, choose Data and fields, then Save to a database, and click Add. The step goes under Then.
  3. In Data source:, pick the source from step 1.
  4. In Table:, pick a table, or type the name of a new one, such as dbo.Invoices.
  5. For a new table, click Create table. It makes the table and fills in the SQL that adds a row to it. Careful: if a table with that name is already there, it is deleted with everything in it and made again. The program asks first.
  6. In Run:, choose For each saved file or Once per email.
  7. Click Test SQL. It runs the SQL with a sample email’s values and adds a row, so you can check the table.
  8. Click Save to save the rule.
The Rule Editor with a Save to a database step: data source, table dbo.Invoices, an INSERT statement with fields, and the Test SQL and Create table buttons
A Save to a database step: the data source, the table and the SQL with its fields.

To change the SQL, edit it in SQL: and click Fields… to insert fields. Each field, such as {FROM} or {SUBJECT}, goes into the SQL as a value. {TABLE_NAME} is the table you chose. Separate several statements with ;.

The step can sit after other steps. For example, convert a file to PDF first, then save its details to the database. See chained rules and actions.

Now click Connect and Download, or let the schedule run. The Downloads tab shows whether each step worked.

That’s it! The program now saves your emails and attachments to a database.

Important considerations

  • 64-bit ODBC driver: version 4.0 is 64-bit only, so it needs your database’s 64-bit ODBC driver. A data source set up for a 32-bit driver in version 3.x needs the 64-bit driver. A driver missing on this computer shows “(not installed on this computer)” next to its name.
  • Connection strings vary: each database has its own, and you may need to try a few. If your connection string names a driver, it must match the one you picked exactly, space for space.
  • Create table may not suit every database. If it fails, make the table in your database yourself, then write the SQL that adds a row to it.
  • The file itself in the table: Create table asks whether to also keep each whole file in a BLOB column. This is not recommended: the table grows quickly. The saved file’s path is usually enough: {SAVE_PATH} is the folder and {FILENAMEEXT} the file name.
  • Running as a service: the service uses the settings it got when it was installed. After you change a rule or a data source, click Reinstall… on Schedule › Service schedule.

More ways to use a database

  • Read the values first: the Parser reads invoice numbers, dates, totals and table lines out of emails and files. With PRO Rules Server it can send them straight to a database with its SQL output.
  • Load rows from Excel or CSV attachments into a table with the Store CSV / SQL step. See Read Excel and CSV attachments.
  • Look a value up, such as a customer code from the sender’s address, with Look up from a database, and use it in folder names, file names and later steps.
  • Watch a database table: each new row goes through your rules, as an email does. See database tables as a source.

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.