Watch with Filemask, Delete after Sending
Previous Topic  Next Topic 



This example demonstrates how to use the watch directory features of NetMailBot. Specifically, a directory is watched for new files matching a specified file mask; when new files are found, they are sent to the recipient as an email attachment. After the email is sent, the files in the directory being watched are deleted.  


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


Prepared Example Files



The -watchdir 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 one file and a directory containing three more files:



Batch File Contents


This is the content of the batch file:


netmailbot.exe -to -from -server localhost -watchdir "c:\tmp\watch" -watchdelete -filemask "*.txt" 




  1. Unzip the file. This will produce a directory called "WatchFilemaskAndDelete". Open this directory.
  2. Open Notepad and edit the batch file "WatchFilemaskAndDelete.bat". Open Notepad and edit the batch file "WatchFilemaskAndDelete.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. Go to the directory "c:\tmp\watch" to ensure the files attach1.txt and attach3.txt have been deleted, but attach2.log has not.
  3. Check your email account for an email containing the file attachments attach1.txt and attach3.txt.