Access Database Using Two Tables
Previous Topic  Next Topic 

Purpose

 

This example demonstrates how to send an email using the mail merge features in NetMailBot, while using two database tables. The notable aspect of this example is that -dbquery uses a SQL Join to query data from two tables to be used in the mail merge. The database used is an MS Access database (Access 2000 version) which contains some sample data.

 

NOTE: You should change the email addresses in the Access database to your own email address(es) before running a test. 

 

Additional Prerequisites

 

Using this feature requires Microsoft Access and working knowledge of creating and editing an MS Access database. Also required is understanding of basic SQL concepts including multi-table joins.

 

Prepared Example Files

 

 

The -bodyfile parameter in NetMailBot uses full paths. We have assumed a particular path as shown in the batch file contents below. Therefore, download this file to C:\tmp on your hard drive or edit the -bodyfile parameter to reflect wherever you unzip the archive.

 

The archive contains two files:

 

 

Batch File Contents

 

This is the content of the batch file:

 

netmailbot -to test@exclamationsoft.com -from test@exclamationsoft.com -subject "Mail Merge Example" -server localhost -logfile c:\tmp\log.txt -dsn "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\tmp\test.mdb" -dbquery "SELECT Customers.first_name, Customers.last_name, Email.email FROM Customers, Email WHERE Customers.ID = Email.customer_id" -dbemailcolumn "email" -dbreplacementids "<<first_name>>=first_name,<<last_name>>=last_name" -body "<<first_name>> <<last_name>>" -personalize

 

Steps

 

  1. Unzip the MailMergeAccess2Tbls.zip file. This will produce a directory called "MailMergeAccess2Tbls". Open this directory.
  2. Open the Access database.
  3. Open the table Email for editing.
  4. Change all of the email addresses to your email address (for the purposes of this test run, they can all be the same).
  5. Close the Access database.
  6. Open Notepad and edit the batch file "MailMergeAccess2Tbls.bat". Note these important parameters used in the batch file:
  1. Invoke the batch file by double-clicking the icon or straight from the command line.
  2. The email recipients retrieved in the query should each receive an email with their name in the message body.