Mail Merge with a CSV (text) file,
Personalizing to, from, subject, and body filename

This example demonstrates how to send an email using the mail merge features in NetMailBot, specifically how to personalize the fields: to, from, subject, and the filename of the email message body. The message body is loaded from a file that is dynamically assigned based on data in the .csv file.
The database used is a text file in CSV format (comma delimited file) which contains some sample data.

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

  • Requirements
    • Working knowledge of creating and editing a batch file.

  • Example Download
    A working example can be downloaded, so that you can follow along with the example:
     Click Here (csv4.zip 1KB)
    The downloadable example is a zip file that contains three files:
    • data.txt - A file containing customer data
    • winner.txt - A file that is a message body
    • loser.txt - A file that is a message body
    • tied.txt - A file that is a message body
    • mail_merge.bat - The batch file that will instruct NetMailBot to send the email message.

    Instructions for Download and Installation

    • Download the example zip file and save it to your hard drive
    • Create a directory on your C drive named "tmp"
    • Unzip all of the files in the example zip file into the newly created directory c:\tmp.

  • Steps
    1. Open the data.txt file by double-clicking on it from My Computer.
    2. Change all of the email addresses to your email address. The email addresses can all be the same.
    3. Save and close data.txt
    4. Open Notepad and edit the batch file mail_merge.bat.

      Some important parameters used in the batch file

      • Change the parameters: -to test@exclamationsoft.com -from test@exclamationsoft.com to your own email address.
      • Change the parameter: -server localhost to your own mail server
      • Note the use of -dsn "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\tmp\;Extended properties=Text;". This is a normal connection string that instructs NetMailBot on how to connect to the data.txt file. NOTE: You should have install latest ODBC drivers on your system should you encounter any ODBC errors.
      • -dbquery "SELECT * FROM data.txt" instructs NetMailBot to select all of the data from the file data.txt. The file data.txt is considered to be a psuedo database table.
      • -dbemailcolumn "to" instructs NetMailBot to use the data in the "column" named "to" to address the message to the data contained in that column for the current row.
      • The parameter -bodyfile "c:\tmp\<<filename>>" instructs NetMailBot to replace <<filename>> with the data contained in the mapped column for the current row. In this example, each recipient will have a different message body.
        The first recipient will have the message body from the file "winner.txt", the second "loser.txt", and the third "tied.txt".
      • -dbreplacementids "<<name>>=name,<<from>>=from, <<to>>=to,<<subject>>=subject, <<filename>>=filename" instructs NetMailBot to replace the strings with double-angle brackets with the data contained in the mapped column for the current row. For example, in the message body, NetMailBot will replace the string <<name>> with the data contained in the column named "name", and will replace the string <<from>> with the data contained in the column named "from", and so on.
      • -personalize instructs NetMailBot to do make the replacements. Without this parameter specified, NetMailBot will not perform any replacements.
    5. Execute the batch file by double-clicking it in "My Computer".