watchDirectory Help

Help Home
Creating New Tasks
Running Tasks
Task History


Standard versus Pro
Version History


See Also...

Free 30 day evaluation!
Standard version: $79 USD
Professional version: $149 USD
Buy Now!


German Helpfile

German Helpfile

French Helpfile

French Helpfile

Spanish Helpfile

Spanish Helpfile

Privacy Policy

Using the $CALL$ macro

Inside the Send email to, Subject and Body area you can use this macro to let the task call a bat script. This script will have a lot of Environment Variables available to it naming the detected file. The "result" of the script will replace the $CALL$ macro.

When the script is called, the variable WD_EMAIL_PART is set to either "TO" (script called to get email recipients), "SUBJECT" (script called for the subject) or "BODY" (script called to get body text).



Example: dynamically set the subject based on file content

The task is monitoring a directory where log files are created. Those logs are emailed to the support desk and they should check the logs to see if everything is ok. To make the emails with errors stand out more, this script checks the detected file for the word "Error" and changes the subject accordingly.

rem use the FINDSTR command to look for the string Error inside the detected file
FINDSTR /I "Error" "%WD_FILE%"
IF %errorlevel% EQU 0 GOTO :ErrorFound
GOTO :ErrorNotFound

ECHO [ERROR] %WD_FILE_N% Processing completed, Errors were found > "%WD_RESULTFILE%"
ECHO %WD_FILE_N% Processing completed without issues  > "%WD_RESULTFILE%"

Example: send half the emails to John, the other half to Eric

There are 2 employees responsible for processing incoming files. The script below will "distribute" the email notifications to John and Eric evenly.

rem WD_CUREVT contains a unique number assigned to the current event (detected file)
rem when it is an odd number (1, 3, 5, ...) the email should go to John.
rem get the modulo of WD_CUREVT (this will set the MOD variable to 0 or 1).
IF %MOD% EQU 1 GOTO :john

ECHO CC:Help Desk^<^> >> "%WD_RESULTFILE%"

ECHO CC:Help Desk^<^> >> "%WD_RESULTFILE%"
Return to The Email plugin