Save emails and attachments to a database (SQL Server)
In this post, we will explore saving emails and attachments to a database server like SQL Server by setting up an ODBC data source and using a post download Action to save contents of the email and/or attachments to a database.
Any compatible ODBC data source can be used such as MySQL, Oracle and more. This post only explores setting up to save the data in SQL Server.
This feature is available with the Mail Attachment Downloader PRO Server version.
- Let’s start off by adding a new data source — click on the Database tab -> Add ODBC source button
- Provide a name for the source, pick the driver as “SQL Server” from the drop down and then use the Connection string
Server=<computer name>\<SQL Server name>;Database=<DB name>;Trusted_Connection=yes;
An example of these filled in is shown below:
- Click “Test Connection” button to make sure this succeeds. Then click OK.
- At this point a data source has been setup.
- Then create a new rule or edit an existing rule from the “Global filters” tab.
- Under Actions after save click Add action and then choose Save to database. This will add an action under After saving file in the list to the left.
NOTE: The screenshot below shows other actions as well, if you have other actions you can chain the save to database action after those actions have taken place as shown below.
- Pick the Source as the one you provided in Step-2.
- Specify a new table name (or an existing one) and then click “Create Table” if this is a new table and follow the prompts. At this point a new table schema would be created and the SQL would be automatically filled in based on the questions you answered.
- Click “Test SQL” to test connectivity and table row creation, this will add a new row to the table to make sure everything is setup correctly.
- Click the Save button to save the new rule with the Save to DB action.
- Now you can click the Connect And Download button to test out the ability to save to DB.
You have setup the program to automatically save emails and attachments to a database.
Some interesting how-to links and posts for further exploration:
- Save rows inside of a CSV or Excel attached in an email to a SQL database!
- Save to multiple folders from multiple accounts using multiple email rules.
- Send emails automatically after downloading files or attachments or body
- Unzip files, Decrypt pdf’s and run script’s
- Extract data and download emails for invoice processing
- Convert email attachments to different formats
- How email rules work in-depth
Contact us if you have any questions, suggestions about the functionality described in this article.