Purpose
This example demonstrates how to use the watch directory features of NetMailBot while running NetMailBot as a Windows Service.
Specifically, a directory is watched for new files, 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 moved to the specified directory.
Additional Prerequisites
Prepared Example Files
The .ini file (discussed below) in this example uses full paths and assumes that the .zip file has been expanded to C:\tmp. Therefore, download this .zip file to C:\tmp on your hard drive or edit the .ini file to reflect wherever you unzip the archive.
The archive contains ten files:
File Contents
This is the content of the NMBService.ini file:
[Settings]
ServiceName = NMBService
ProcCount = 1
CheckProcess = 60
[Process0]
CommandLine = C:\Program Files\NetMailBot\netmailbot -to email@domain.com -from email@domain.com -server localhost -watchdir "c:\tmp\watch" -watchmoveto "c:\tmp" -logfile "c:\tmp\log.txt"
WorkingDir = C:\Program Files\NetMailBot
PauseStart = 0
PauseEnd = 3000
UserInterface = No
Restart = No
All of the .bat files invoke NMBService.exe with various parameters to effect the desired outcome.
This is the content of the NMBStart Service.bat file:
NMBService -r NMBService
This is the content of the NMBStop Service.bat file:
NMBService -k NMBService
This is the content of the NMBService Install.bat file:
NMBService -k NMBService
NMBService -u
NMBService -i
NMBService -r NMBService
@pause
This is the content of the NMBService UNInstall.bat file:
NMBService -k NMBService
NMBService -u
pause
Steps