watchDirectory Help

Help Home
Creating New Tasks
Running Tasks
Task History

Plugins

Standard versus Pro
Version History

Search

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).

Syntax

$CALL:C:\Full\path\to\batfile.bat$

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

:ErrorFound
ECHO [ERROR] %WD_FILE_N% Processing completed, Errors were found > "%WD_RESULTFILE%"
GOTO :EOF
:ErrorNotFound
ECHO %WD_FILE_N% Processing completed without issues  > "%WD_RESULTFILE%"
GOTO :EOF

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).
SET /A MOD=%WD_CUREVT% % 2
IF %MOD% EQU 1 GOTO :john

ECHO eric@example.com > "%WD_RESULTFILE%"
ECHO CC:Help Desk^<support@example.com^> >> "%WD_RESULTFILE%"
GOTO :EOF

:john
ECHO john@example.com > "%WD_RESULTFILE%"
ECHO CC:Help Desk^<support@example.com^> >> "%WD_RESULTFILE%"
Return to The Email plugin