Extract data from emails and integrate your business systems

Pick emails and files, read the values in them and pass them to your other systems, on a schedule or 24×7 as a Windows service.

This post shows how to extract data from emails, automate the work that follows and cut out repetitive tasks. It also gives an overview of how to connect your line-of-business systems with Mail Attachment Downloader 4.0.

Note: this is a high-level overview. For a step-by-step look at rules, see PRO Rules and moving from account settings to PRO Rules.

Automate email with attachments

What options do you have?

Mail Attachment Downloader PRO is a cost-effective way to automate email in your business. It runs on your own system, on a PC, a server or a cloud VM, and reads your mail server directly, with no cloud service in between.

The work is done by rules. Set up as many as you need, for one account or for all of them at once. In 4.0, rules live in the PRO Rules tab, the new name of 3.x’s Global filters. Each edition adds to the one before: PRO Backup, PRO Parser, PRO Rules Client and PRO Rules Server. See which edition fits.

The PRO Rules tab with a shared filter for supplier invoices, rules under it, and rules that convert, OCR and send orders on
The PRO Rules tab: each rule has its own conditions, save folder and steps.

Scheduled processing

Every PRO edition can download on a schedule from Schedule › App schedule, and pick up new mail as it arrives.

With PRO Rules Server, the same work runs 24×7 as a Windows service, installed from Schedule › Service schedule. It keeps running when nobody is signed in, and starts again by itself after a restart (Auto start on bootup). It runs on Windows Server or Windows 10 and later, so on a PC, a server or a cloud VM in Azure, AWS and others. See the PRO Rules Server how-to.

Schedule › Service schedule before the service is installed, with Install the service for, Check every and Auto start on bootup
Schedule › Service schedule: pick the account, how often to check, and click Install service.

Order of rules

Rules run from the top of the list down. Each email or file goes to the first rule that takes it. Rule settings › Check rule order… finds rules that can never save anything because a rule above takes their files. Test all rules… tries your rules on real emails without moving, deleting or sending anything.

The parts of a rule

A 3.x rule had four phases: search, extract, save and process. In 4.0 you build a rule in the Rule Editor, and the same ideas are its sections:

  • Which emails: the conditions, such as sender, subject, dates, attachment name, account or folder, with AND / OR groups.
  • Fields to find: values read from the email, such as an order number, for file names and steps.
  • Save: the attachments, the email or both, where, and how files are named. A network share works too (use a UNC path such as \\server\share).
  • Then: the steps that run after saving, in order. Steps can hold other steps: unzip a file, convert what is inside to PDF, then save its details to a database.
  • If something fails: what runs when a step fails, such as alerting your team.
The Rule Editor with Which emails, Fields to find, Save, Then and If something fails, and steps nested under Find fields with AI
The Rule Editor: steps under Then run in order, and nested steps work on the result of the step above them.

Prefer to describe it? On the AI Assistant tab, say in plain words which emails to take and what to do, and the AI builds the rule. The built-in AI runs on your own system; a cloud AI is used only once you choose it.

Multiple accounts and other sources

To limit a rule to one account, add an Account condition under Which emails. Rules also run on watches (PRO Rules Client and up): new files in folders, network shares, SharePoint, OneDrive or S3, and completed DocuSign envelopes. PRO Rules Server adds database tables, Slack and Teams. See Watches.

Integrate with your other systems

Steps under Then hand files and values to the systems you already use: Upload to cloud and Send to document management (Laserfiche, M-Files, DocuWare) from PRO Rules Client, and Save to a database, Web hook, Send to Zapier and Run a script in PRO Rules Server. For processing in your own code, a plugin API takes your own C# step. Contact us for more.

Common uses

Conclusion

Mail Attachment Downloader 4.0 PRO automates the data in your email on your own system: a PC, a server or a cloud VM. Rules pick the emails and files, read the values, save them your way and hand them on, and PRO Rules Server keeps it running 24×7.

Have a use case that isn’t covered, or need help connecting your back-end systems? Let us know.

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.

Email actions: unzip an attachment, convert to PDF, decrypt a PDF and run a script

Unzip email attachments, convert or decrypt each file as PDF, then run a script on the result: steps inside steps in Mail Attachment Downloader.

This post shows how to set up a rule that unzips an email attachment, converts each file inside to PDF (or removes a PDF’s password), and then runs a script on the result. It is written for version 4.0.

Which edition you need:

You start from a rule with its conditions and its Save part set up, for example for the emails from acme.example, saved to \\fileserver\Finance\Invoices. New to rules? See save emails and attachments to folders.

Steps work on the saved files. To run them on the email itself too, set What to save to The email and its attachments: the email is then saved as an .eml file, and Convert documents can turn it into a PDF.

1. Unzip the attachment

In the Rule Editor, click Add a step…, find Unzip (type “zip” in the search box) and click Add. It goes under Then. Its options:

  • Only these files: one file name or extension per line, such as .docx and .pdf. Leave it empty to unzip every file.
  • Delete the zip file after unzipping it, if you only want the files inside.
  • Keep the folders inside the zip, to keep the zip’s own folders.
The Rule Editor with an Unzip step under Then, and its options: Delete the zip file after unzipping it, Only these files and Keep the folders inside the zip
The Unzip step and its options.

2. Convert each unzipped file, inside Unzip

Steps inside the Unzip step run for each file it unzips. To add one there:

  1. Select Unzip in the rule’s outline.
  2. Click Add a step… and, in the Add it: box, choose Inside “Unzip”.
  3. Pick Convert documents and click Add.

In the Convert documents step, click Add… to add a conversion. In the Conversion window, choose what is converted in From:, choose pdf in To:, and set the result’s name in Save as:, such as {SAVE_PATH}\{FILENAME}.pdf. Add one conversion for each kind of file, for example Word files and pictures. Tick Delete the originals after converting them if you only want the PDFs.

The Conversion window: From, To pdf, Save as with fields, Run the rules on the result, Convert with Free libraries, and the options for pictures and for the PDF made
The Conversion window of the Convert documents step.

Decrypt a PDF

Do the files arrive as password-protected PDFs? Add a conversion from PDF to pdf, with a new name in Save as: such as {SAVE_PATH}\{FILENAME}_open.pdf. Under A PDF converted, type the password in Decryption password:. The PDF it saves has no password. Remove the restrictions also drops limits such as no printing or no copying. It works the other way too: Encrypt the PDF, under The PDF made, adds a password to the PDFs you make.

The Conversion window: from PDF to pdf, saved as the file name with _open, and under A PDF converted a masked Decryption password
A PDF converted: the password opens a protected PDF, and the copy is saved without it.

3. Run a script on the converted file, inside Convert documents

Now select Convert documents, click Add a step…, choose Inside “Convert documents” in the Add it: box, and pick a step from Programs:

  • Run a script runs a script with the fields and waits for it to finish. Set the Program: (a .bat or .exe file, or powershell.exe for a PowerShell script), its Arguments: and a Timeout (seconds):. What it prints goes to the program’s logs.
  • Run a command line runs a program or a .bat file with the fields: set the Command: and its Arguments:.

Click Fields… to add fields to the arguments. Inside Convert documents, {SAVE_PATH} and {FILENAMEEXT} are the converted PDF, not the zip or the file it was made from. For example, with powershell.exe as the program, the arguments could be -File "C:\Scripts\ArchiveInvoice.ps1" "{SAVE_PATH}\{FILENAMEEXT}" "{EMAIL_FROM}".

Run: says whether the step runs For each saved file or Once per email. Click Run it once (test) to try it with a sample email’s values.

The Run a command line step: Command C:\Tools\ArchiveInvoice.exe, Arguments with the SUPPLIER, SAVE_PATH and FILENAMEEXT fields, Run For each saved file, and Run it once (test)
A Run a command line step, with fields in its arguments.

The finished rule

The rule’s outline now reads:

  • Then
    • Unzip
      • Convert documents
        • Run a script

Each zip is unzipped, each file inside is converted to PDF, and the script runs once for each PDF.

The Rule Editor of the rule Acme invoice zips: under Then, Unzip, with Convert documents inside it and Run a script inside that, running powershell.exe with -File and the saved file
Steps inside steps: Unzip, then Convert documents on each file, then Run a script on each PDF.

Click Test this rule… to try it on emails you pick. Unzipping and converting are done for real, into a temporary folder, so you can open the PDFs. The script is only described, not run. Then click Save.

A step can fail, for example when a PDF’s password is wrong. Steps under If something fails, such as Move or copy the email or Send notification, tell you or set the email aside. The program also tries a failed step again by itself. See nesting email rules and actions.

More steps for files

Other steps go well with these: Convert all files to a single PDF, Merge PDFs, Split PDF and Make PDFs searchable (OCR) (PRO Rules Server), and Upload to cloud or Copy file (PRO Rules Client and up). Need a step that isn’t there? Contact us and we’ll look at it.

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

PDF to DOCX conversion and more, straight from your email

Email a PDF to a mailbox and get a Word (.docx) file in your folder: convert PDF attachments to DOCX, TIFF, pictures and more automatically.

Need a PDF as a Word file? Email it as an attachment to a mailbox of your choice. Mail Attachment Downloader picks it up, converts it to DOCX and saves it in the folder you want.

Converting to formats other than PDF needs PRO Rules Server. It can also run as a Windows service, 24×7, with nobody signed in, on a PC, a server or a cloud VM. So the conversion happens even when your own computer is off. This post is written for version 4.0.

Set up PDF to DOCX

  1. Open the PRO Rules tab. Click New rule…, or select a rule and click Edit. Give a new rule a name you’ll recognize, such as “PDF to Word”.
  2. Under Which emails, add the conditions, for example To ‘convert@contoso.com’ and Attachment name ‘.pdf’. Under Save, set the Save folder, for example \\fileserver\Finance\Converted.
  3. Click Add a step…, choose Files, then Convert documents, and click Add.
  4. In the step, click Add…. In the Conversion window, set From: to Any pdf (pdf, latex etc.) and To: to docx.
  5. In Save as:, set the new file’s name, for example {SAVE_PATH}\{FILENAME}.docx. Click OK.
  6. Click Save. That’s it!

From now on, each PDF attachment that matches the rule is saved and converted to DOCX. Tick Delete the originals after converting them in the step if you want only the Word files.

The Conversion window with From set to Any pdf (pdf, latex etc.), the To and Save as boxes, and options for pictures and PDFs
The Conversion window. Set From to PDFs, and To to docx.
The Conversion window: from Any pdf to docx, saved as {SAVE_PATH}\{FILENAME}.docx, with Default as the engine, and under A PDF converted a masked Decryption password, Remove the certificate and Remove the restrictions
PDF to DOCX, with the options for protected PDFs.

Password-protected PDFs

A PDF with a password has to be opened before it can be converted. In the Conversion window, under A PDF converted, type the Decryption password:. You can also tick Remove the restrictions or Remove the certificate.

Only need some of the pages? Type them in Pages to convert:, for example 1-3, 7. Empty converts every page.

More than DOCX

The same step converts PDFs to other formats too, such as DOC, Excel, PowerPoint, HTML, XPS, text, multi-page TIFF, PNG and JPEG. Just pick another To:. For pictures, set the Resolution (dpi): and TIFF compression: under Pictures (to JPEG, PNG or TIFF).

It works the other way round as well. With PRO Rules Server, emails (.eml, .msg, .txt, .html) and attachments (Word, Excel, PowerPoint, pictures and more) convert to 59 formats:

  • DOCX to PDF, PNG, JPEG, HTML and more
  • PDF to DOCX, PNG, JPEG, HTML and more
  • CSV, XLSX to PDF, PNG, JPEG, HTML and more
  • PPTX to PDF, PNG, JPEG, HTML and more
  • EML to PDF, DOCX, PNG, JPEG, HTML and more
  • JPEG, BMP, TIFF and other pictures to PDF, DOCX, HTML and more

Converting to PDF only? That needs just PRO Rules Client. See Convert emails to PDF or TIFF.

Keep it running

To convert around the clock, install the program as a Windows service on Schedule › Service schedule. The service uses the settings it got when it was installed, so reinstall it there after you change a rule. See Run as a Windows service.

The Downloads tab shows each email the rule took, and whether the conversion worked. Each email is handled once: the program remembers it in its History, so nothing is converted twice.

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

Convert emails to PDF or TIFF, including email attachments

Save emails and their attachments as PDF, TIFF or 50+ other formats automatically, one file each or merged into one PDF, with Mail Attachment Downloader.

Mail Attachment Downloader can save your emails and their attachments as PDF files. With PRO Rules Server it can also make multi-page TIFF files, Word files, pictures and more than 50 other formats.

All of it is one step in a rule: Convert documents. This post shows how to set it up in version 4.0.

Which edition converts to what

  • PRO Rules Client converts emails and attachments to PDF, and can protect the PDF with a password.
  • PRO Rules Server also converts to TIFF, DOCX, PNG, JPEG, HTML and the other formats. It also merges an email and its attachments into one PDF.

If your edition can’t make the format you pick, the conversion window says so: “Only PRO Server converts to other types than PDF.” See plans and prices.

Convert attachments to PDF or TIFF

  1. Open the PRO Rules tab. Click New rule…, or select a rule and click Edit. The Rule Editor opens.
  2. Under Which emails, set the conditions, for example From ‘acme.example’. Under Save, choose What to save and the Save folder, for example \\fileserver\Finance\Invoices.
  3. Click Add a step…, choose Files, then Convert documents, and click Add. The step goes under Then.
  4. In the step, click Add…. The Conversion window opens.
  5. In From:, choose the kind of file to convert, for example Any doc (doc, docx, txt, html etc.). Other kinds cover PDFs, spreadsheets, slides, pictures and emails, and All possible takes every kind (to PDF only).
  6. In To:, choose pdf or, with PRO Rules Server, tiff or another format.
  7. In Save as:, set the converted file’s name. Click Fields… to insert fields, for example {SAVE_PATH}\{FILENAME}.pdf.
  8. Click OK. Add one conversion for each kind of file you get: Word files, Excel sheets, slides, pictures.
  9. Tick Delete the originals after converting them if you want only the converted files in the folder.
  10. Click Save.
The Rule Editor with a Convert documents step under Then, with Add, Edit and Remove buttons for its conversions and the Delete the originals after converting them option
A Convert documents step. Each conversion in it handles one kind of file.
The Conversion window: From, To, Save as, picture options with TIFF compression, and the PDF options Fit to page, No margins and Encrypt the PDF
The Conversion window: what is converted, what it becomes, and the options for pictures and PDFs.

Each attachment of a matching email is now saved, then converted. Want to see it first? Click Test this rule… on the PRO Rules tab. It runs the rule on emails you pick and shows what it would save. Nothing is changed.

Converting several kinds in one step? Tick Ignore failures (when several types are converted), so one file that can’t be converted doesn’t stop the others.

Save the email itself as PDF or TIFF

The email’s own text can be converted too. In Save, set What to save to The email and its attachments, or The email only. The email is saved as an .eml file, which counts as a document for conversion.

Then add a conversion from Any email (.eml, .msg etc.) to pdf or tiff. The Conversion window has options for emails:

  • Skip the email’s header (emails), to leave out its header.
  • Skip the attachments it can show inside (emails), when you convert the attachments separately.
  • The email’s date in this computer’s time zone (emails).

TIFF and picture options

When To: is a picture format, the Pictures (to JPEG, PNG or TIFF) options apply: Resolution (dpi):, Quality: and TIFF compression:. A document with several pages becomes one multi-page TIFF file.

Protect the PDF with a password

Under The PDF made, tick Encrypt the PDF. Choose the Algorithm: and type an Owner password: and a User password:.

One PDF for each email

The steps above make a separate PDF for each attachment. To get one PDF per email, with the email first and its attachments after it, use Convert all files to a single PDF (PRO Rules Server). It adds a Convert documents step and a Merge PDFs step in one go. See merge email attachments into a single PDF.

More than 50 formats

With PRO Rules Server, emails (.eml, .msg, .txt, .html) and attachments (Word, Excel, PowerPoint, pictures and more) convert to 59 formats. The popular ones:

  • DOCX to PDF, multi-page TIFF, PNG, JPEG, HTML and more
  • PDF to DOCX, multi-page TIFF, PNG, JPEG, HTML and more
  • CSV, XLSX to PDF, multi-page TIFF, PNG, JPEG, HTML and more
  • PPTX to PDF, multi-page TIFF, PNG, JPEG, HTML and more
  • EML to PDF, multi-page TIFF, DOCX, PNG, JPEG, HTML and more
  • JPEG, BMP, TIFF and other pictures to PDF, DOCX, HTML and more

The whole list is on the features page. For PDF to Word, see PDF to DOCX conversion and more.

More in 4.0

  • Steps after the conversion: tick Run the rules on the result in a conversion, or put steps after it, to upload, merge or send the converted file. See steps under steps.
  • Scanned PDFs: Make PDFs searchable (OCR) adds a text layer (PRO Rules Server). See OCR.
  • A PDF archive of old mail: with PRO Backup, the Backup tab can export the emails it keeps to PDF, with no rule at all. See Export.

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.