Attach and ZIP Compress .txt Files from a Directory
Previous Topic  Next Topic 

Purpose

 

This example demonstrates how to use the parameters -attachmentdir-zip, and -filemask. The -attachmentdir parameter specifies a directory from which to retrieve files to attach. The -zip parameter instructs NetMailBot to compress all of the files into a single attachment, optionally with a specific name that you specify. The -filemask parameter instructs NetMailBot to only work with the files that match the given file mask.

 

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

 

Prepared Example Files

 

 

Check this paragraph: The -attachmentdir 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 -attachmentdir parameter to reflect wherever you unzip the archive.

 

The archive contains four files:

 

 

Batch File Contents

 

This is the content of the batch file:

 

netmailbot.exe -to test@exclamationsoft.com -from test@exclamationsoft.com -server localhost -attachmentdir "c:\tmp" -zip -filemask "*.txt"

 

Steps

 

  1. Unzip the AttachAndZIPFromDir.zip file. This will produce a directory called "AttachAndZIPFromDir". Open this directory.
  2. Open Notepad and edit the batch file "AttachAndZIPFromDir.bat". Note these important parameters used in the batch file:

 

 

NOTE: If you do specify a custom filename for your attachment, e.g. -zip "myatt.zip", make sure not to forget to specify the .zip extension, that is, don't specify a name like -zip "myatt". If you do forget, some mail clients might receive the attachment as e.g. "myatt.dat", and will most likely prevent the recipient from being able to open the attachment for security reasons. ".zip" is likely to be a trusted file type, so your recipients should be able to open the attachment.

 

  1. Invoke the batch file by double-clicking the icon or straight from the command line.
  2. Check your email account for an email containing a single attachment named "attachment.zip".