{"id":33,"date":"2016-02-22T10:25:46","date_gmt":"2016-02-22T10:25:46","guid":{"rendered":"http:\/\/gearmage.com\/blog\/?p=33"},"modified":"2026-11-25T20:14:40","modified_gmt":"2026-11-25T20:14:40","slug":"save-emails-and-attachments-to-a-database","status":"publish","type":"post","link":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/","title":{"rendered":"Save emails and attachments to a database (SQL Server and any ODBC database)"},"content":{"rendered":"\n<p>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 <strong>Save to a database<\/strong> step to a rule. Each time the rule saves a file, a row goes into your table.<\/p>\n<p>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.<\/p>\n\n<h2>An overview: emails to databases<\/h2>\n<p>Database steps are part of <a href=\"https:\/\/gearmage.com\/buymaildownloader.html\">PRO Rules Server<\/a>.<\/p>\n<ul>\n<li>You don&#8217;t need to know SQL. <strong>Create table<\/strong> makes a table and writes the SQL for you.<\/li>\n<li>If you do know SQL, you can change the statement to suit your own tables.<\/li>\n<li>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.<\/li>\n<\/ul>\n<p>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 <strong>Save to a database<\/strong> is one of them.<\/p>\n<p>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.<\/p>\n\n<h2>Step by step: emails to a database<\/h2>\n\n<h3>1. Set up a data source<\/h3>\n<p>Open the <strong>Settings<\/strong> tab, go to <strong>Sources<\/strong>, choose <strong>Data Sources<\/strong> and click <strong>Add&#8230;<\/strong>. The <strong>Data source configuration<\/strong> window opens.<\/p>\n<ol>\n<li>Give the source a name in <strong>Name:<\/strong>, for example &#8220;Contoso Finance&#8221;.<\/li>\n<li>Pick the driver in <strong>Choose driver:<\/strong>. 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.<\/li>\n<li>Type the <strong>Connection string:<\/strong>. For SQL Server with Windows sign-in it looks like this:<br><code>Server=&lt;computer name&gt;\\&lt;SQL Server instance&gt;;Database=&lt;database name&gt;;Trusted_Connection=yes;<\/code><\/li>\n<\/ol>\n<p>For example:<\/p>\n<p><code>Server=CONTOSO-SQL01\\FINANCE;Database=ContosoInvoices;Trusted_Connection=yes;<\/code><\/p>\n<p>Click <strong>Test connection<\/strong>. Once it says <strong>Connection succeeded.<\/strong>, click <strong>OK<\/strong>. The data source is ready.<\/p>\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gearmage.com\/assets\/images\/4.0-data-source.jpg?w=840&#038;ssl=1\" alt=\"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\"><figcaption>A data source for the database steps: name, 64-bit ODBC driver and connection string, tested.<\/figcaption><\/figure>\n<p>To connect another way, or to another database such as Oracle or MySQL, look up its ODBC connection string, for example on <a href=\"https:\/\/www.connectionstrings.com\/\">connectionstrings.com<\/a>. Choose the ODBC string, not the other kinds.<\/p>\n\n<h3>2. Add a Save to a database step to a rule<\/h3>\n<p>Open the <strong>PRO Rules<\/strong> tab. Click <strong>New rule&#8230;<\/strong>, or select a rule and click <strong>Edit<\/strong>. The Rule Editor opens.<\/p>\n<ol>\n<li>Set the rule&#8217;s conditions under <strong>Which emails<\/strong>, for example <strong>From<\/strong> &#8216;acme.example&#8217; and <strong>Attachment name<\/strong> ending in .pdf, and where the files are saved under <strong>Save<\/strong>, for example <code>\\\\fileserver\\Finance\\Invoices<\/code>.<\/li>\n<li>Click <strong>Add a step&#8230;<\/strong>, choose <strong>Data and fields<\/strong>, then <strong>Save to a database<\/strong>, and click <strong>Add<\/strong>. The step goes under <strong>Then<\/strong>.<\/li>\n<li>In <strong>Data source:<\/strong>, pick the source from step 1.<\/li>\n<li>In <strong>Table:<\/strong>, pick a table, or type the name of a new one, such as <code>dbo.Invoices<\/code>.<\/li>\n<li>For a new table, click <strong>Create table<\/strong>. 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.<\/li>\n<li>In <strong>Run:<\/strong>, choose <strong>For each saved file<\/strong> or <strong>Once per email<\/strong>.<\/li>\n<li>Click <strong>Test SQL<\/strong>. It runs the SQL with a sample email&#8217;s values and adds a row, so you can check the table.<\/li>\n<li>Click <strong>Save<\/strong> to save the rule.<\/li>\n<\/ol>\n\n<figure><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/gearmage.com\/assets\/images\/4.0-database.jpg?w=840&#038;ssl=1\" alt=\"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\"><figcaption>A Save to a database step: the data source, the table and the SQL with its fields.<\/figcaption><\/figure>\n\n<p>To change the SQL, edit it in <strong>SQL:<\/strong> and click <strong>Fields&#8230;<\/strong> to insert fields. Each field, such as <code>{FROM}<\/code> or <code>{SUBJECT}<\/code>, goes into the SQL as a value. <code>{TABLE_NAME}<\/code> is the table you chose. Separate several statements with <code>;<\/code>.<\/p>\n<p>The step can sit after other steps. For example, convert a file to PDF first, then save its details to the database. See <a href=\"https:\/\/gearmage.com\/maildownloader_pro_features.html#chained-actions\">chained rules and actions<\/a>.<\/p>\n<p>Now click <strong>Connect and Download<\/strong>, or let the schedule run. The <strong>Downloads<\/strong> tab shows whether each step worked.<\/p>\n<p>That&#8217;s it! The program now saves your emails and attachments to a database.<\/p>\n\n<h2>Important considerations<\/h2>\n<ul>\n<li><strong>64-bit ODBC driver:<\/strong> version 4.0 is 64-bit only, so it needs your database&#8217;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 &#8220;(not installed on this computer)&#8221; next to its name.<\/li>\n<li><strong>Connection strings vary:<\/strong> 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.<\/li>\n<li><strong>Create table may not suit every database.<\/strong> If it fails, make the table in your database yourself, then write the SQL that adds a row to it.<\/li>\n<li><strong>The file itself in the table:<\/strong> <strong>Create table<\/strong> asks whether to also keep each whole file in a BLOB column. This is not recommended: the table grows quickly. The saved file&#8217;s path is usually enough: <code>{SAVE_PATH}<\/code> is the folder and <code>{FILENAMEEXT}<\/code> the file name.<\/li>\n<li><strong>Running as a service:<\/strong> the service uses the settings it got when it was installed. After you change a rule or a data source, click <strong>Reinstall&#8230;<\/strong> on <strong>Schedule<\/strong> \u203a <strong>Service schedule<\/strong>.<\/li>\n<\/ul>\n\n<h2>More ways to use a database<\/h2>\n<ul>\n<li><strong>Read the values first:<\/strong> the <a href=\"https:\/\/gearmage.com\/maildownloader_pro_features.html#parser\">Parser<\/a> reads invoice numbers, dates, totals and table lines out of emails and files. With <a href=\"https:\/\/gearmage.com\/buymaildownloader.html#plan-server\">PRO Rules Server<\/a> it can send them straight to a database with its SQL output.<\/li>\n<li><strong>Load rows from Excel or CSV attachments<\/strong> into a table with the <strong>Store CSV \/ SQL<\/strong> step. See <a href=\"https:\/\/gearmage.com\/maildownloader_pro_features.html#csv-excel\">Read Excel and CSV attachments<\/a>.<\/li>\n<li><strong>Look a value up<\/strong>, such as a customer code from the sender&#8217;s address, with <strong>Look up from a database<\/strong>, and use it in folder names, file names and later steps.<\/li>\n<li><strong>Watch a database table:<\/strong> each new row goes through your rules, as an email does. See <a href=\"https:\/\/gearmage.com\/maildownloader_pro_features.html#src-databases\">database tables as a source<\/a>.<\/li>\n<\/ul>\n\n<p><strong>Try it:<\/strong> <a href=\"https:\/\/gearmage.com\/maildownloader.html\">download Mail Attachment Downloader<\/a> and start with <a href=\"https:\/\/gearmage.com\/buymaildownloader.html#plan-free\">the free edition<\/a>, or <a href=\"https:\/\/gearmage.com\/buymaildownloader.html\">compare the PRO editions<\/a>, each with a 30-day money-back guarantee.<\/p>\n\n<h2>Related<\/h2>\n<ul>\n<li><a href=\"https:\/\/gearmage.com\/emails-to-database.html\">Save emails, files and invoice data to a database<\/a><\/li>\n<li><a href=\"https:\/\/gearmage.com\/maildownloader_pro_features.html#database\">Databases: features<\/a><\/li>\n<li><a href=\"https:\/\/gearmage.com\/maildownloader_pro_features.html#parser-output\">Parser output: CSV, Excel, Google Sheets, a database and more<\/a><\/li>\n<li><a href=\"https:\/\/gearmage.com\/blog\/multiple-email-accounts-via-rules\/\">Multiple email accounts and multiple rules<\/a><\/li>\n<li><a href=\"https:\/\/gearmage.com\/maildownloader_pro_service.html\">Run as a Windows service (PRO Rules Server how-to)<\/a><\/li>\n<li><a href=\"https:\/\/gearmage.com\/buymaildownloader.html\">Plans and prices<\/a><\/li>\n<li>Using version 3.x? See the <a href=\"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database-3x\/\">3.x version of this guide<\/a>.<\/li>\n<\/ul>\n<p>Questions or suggestions about this post? <a href=\"https:\/\/gearmage.com\/contact.html\">Contact us<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n","protected":false},"author":1,"featured_media":1152,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[121,4,6],"tags":[13,16],"class_list":["post-33","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-databases","category-mad","category-tips","tag-save-emails-to-a-database","tag-sql-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Save emails and attachments to a database - Gearmage Blog<\/title>\n<meta name=\"description\" content=\"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.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Save emails and attachments to a database - Gearmage Blog\" \/>\n<meta property=\"og:description\" content=\"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.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/\" \/>\n<meta property=\"og:site_name\" content=\"Gearmage Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-22T10:25:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-25T20:14:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2026\/11\/4-0-database.jpg?fit=1400%2C956&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"1400\" \/>\n\t<meta property=\"og:image:height\" content=\"956\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"gearmage\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"gearmage\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/\"},\"author\":{\"name\":\"gearmage\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#\\\/schema\\\/person\\\/c8728645787bff3555b5873b43161652\"},\"headline\":\"Save emails and attachments to a database (SQL Server and any ODBC database)\",\"datePublished\":\"2016-02-22T10:25:46+00:00\",\"dateModified\":\"2026-11-25T20:14:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/\"},\"wordCount\":1079,\"publisher\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/gearmage.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/4-0-database.jpg?fit=1400%2C956&ssl=1\",\"keywords\":[\"save emails to a database\",\"SQL Server\"],\"articleSection\":[\"Databases and spreadsheets\",\"Mail Attachment Downloader\",\"Tips\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/\",\"url\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/\",\"name\":\"Save emails and attachments to a database - Gearmage Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/gearmage.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/4-0-database.jpg?fit=1400%2C956&ssl=1\",\"datePublished\":\"2016-02-22T10:25:46+00:00\",\"dateModified\":\"2026-11-25T20:14:40+00:00\",\"description\":\"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.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/gearmage.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/4-0-database.jpg?fit=1400%2C956&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/gearmage.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/4-0-database.jpg?fit=1400%2C956&ssl=1\",\"width\":1400,\"height\":956,\"caption\":\"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\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/save-emails-and-attachments-to-a-database\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Save emails and attachments to a database (SQL Server and any ODBC database)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/\",\"name\":\"Gearmage Blog\",\"description\":\"Email Processing Tools and Solutions\",\"publisher\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#organization\",\"name\":\"Gearmage\",\"url\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/gearmage.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/cropped-cropped-GearMage.jpg?fit=240%2C58&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/gearmage.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/cropped-cropped-GearMage.jpg?fit=240%2C58&ssl=1\",\"width\":240,\"height\":58,\"caption\":\"Gearmage\"},\"image\":{\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/gearmage.com\\\/blog\\\/#\\\/schema\\\/person\\\/c8728645787bff3555b5873b43161652\",\"name\":\"gearmage\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ca0fad01f9a63241bc21d4f1f44befe7c62e4ee3bb268fb1adaadc2e49ed0699?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ca0fad01f9a63241bc21d4f1f44befe7c62e4ee3bb268fb1adaadc2e49ed0699?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ca0fad01f9a63241bc21d4f1f44befe7c62e4ee3bb268fb1adaadc2e49ed0699?s=96&d=mm&r=g\",\"caption\":\"gearmage\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Save emails and attachments to a database - Gearmage Blog","description":"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.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/","og_locale":"en_US","og_type":"article","og_title":"Save emails and attachments to a database - Gearmage Blog","og_description":"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.","og_url":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/","og_site_name":"Gearmage Blog","article_published_time":"2016-02-22T10:25:46+00:00","article_modified_time":"2026-11-25T20:14:40+00:00","og_image":[{"width":1400,"height":956,"url":"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2026\/11\/4-0-database.jpg?fit=1400%2C956&ssl=1","type":"image\/jpeg"}],"author":"gearmage","twitter_card":"summary_large_image","twitter_misc":{"Written by":"gearmage","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/#article","isPartOf":{"@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/"},"author":{"name":"gearmage","@id":"https:\/\/gearmage.com\/blog\/#\/schema\/person\/c8728645787bff3555b5873b43161652"},"headline":"Save emails and attachments to a database (SQL Server and any ODBC database)","datePublished":"2016-02-22T10:25:46+00:00","dateModified":"2026-11-25T20:14:40+00:00","mainEntityOfPage":{"@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/"},"wordCount":1079,"publisher":{"@id":"https:\/\/gearmage.com\/blog\/#organization"},"image":{"@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2026\/11\/4-0-database.jpg?fit=1400%2C956&ssl=1","keywords":["save emails to a database","SQL Server"],"articleSection":["Databases and spreadsheets","Mail Attachment Downloader","Tips"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/","url":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/","name":"Save emails and attachments to a database - Gearmage Blog","isPartOf":{"@id":"https:\/\/gearmage.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/#primaryimage"},"image":{"@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2026\/11\/4-0-database.jpg?fit=1400%2C956&ssl=1","datePublished":"2016-02-22T10:25:46+00:00","dateModified":"2026-11-25T20:14:40+00:00","description":"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.","breadcrumb":{"@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/#primaryimage","url":"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2026\/11\/4-0-database.jpg?fit=1400%2C956&ssl=1","contentUrl":"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2026\/11\/4-0-database.jpg?fit=1400%2C956&ssl=1","width":1400,"height":956,"caption":"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"},{"@type":"BreadcrumbList","@id":"https:\/\/gearmage.com\/blog\/save-emails-and-attachments-to-a-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gearmage.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Save emails and attachments to a database (SQL Server and any ODBC database)"}]},{"@type":"WebSite","@id":"https:\/\/gearmage.com\/blog\/#website","url":"https:\/\/gearmage.com\/blog\/","name":"Gearmage Blog","description":"Email Processing Tools and Solutions","publisher":{"@id":"https:\/\/gearmage.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gearmage.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/gearmage.com\/blog\/#organization","name":"Gearmage","url":"https:\/\/gearmage.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gearmage.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2016\/02\/cropped-cropped-GearMage.jpg?fit=240%2C58&ssl=1","contentUrl":"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2016\/02\/cropped-cropped-GearMage.jpg?fit=240%2C58&ssl=1","width":240,"height":58,"caption":"Gearmage"},"image":{"@id":"https:\/\/gearmage.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/gearmage.com\/blog\/#\/schema\/person\/c8728645787bff3555b5873b43161652","name":"gearmage","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ca0fad01f9a63241bc21d4f1f44befe7c62e4ee3bb268fb1adaadc2e49ed0699?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ca0fad01f9a63241bc21d4f1f44befe7c62e4ee3bb268fb1adaadc2e49ed0699?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ca0fad01f9a63241bc21d4f1f44befe7c62e4ee3bb268fb1adaadc2e49ed0699?s=96&d=mm&r=g","caption":"gearmage"}}]}},"jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/gearmage.com\/blog\/wp-content\/uploads\/2026\/11\/4-0-database.jpg?fit=1400%2C956&ssl=1","_links":{"self":[{"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":23,"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":1402,"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/posts\/33\/revisions\/1402"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/media\/1152"}],"wp:attachment":[{"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gearmage.com\/blog\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}