watchDirectory Help > Plugins > Automatically Email > Advanced Addressing Options
Advanced Addressing
Using Variables
You can use several variables related to the file event that just happened in the email address. This lets you route the emails to specific email boxes depending on the event. For example, to send the email to "john_filenew@home.com" when a new file is created, and to "john_filedel@home.com" when a file is deleted, you should enter the email address as follows:TO:<john_%WD_REASON%@home.com>If you use variables that relate to the file or directoryname, backslashes, colons and spaces are replaced by underscores. For example, if you use the %WD_RELDIR% variable (contains the part of the directory "after" the monitored directory), and an email is sent for the file C:\MonitoredDirectory\Subdir1\Subdir2\NewFile.txt, the address
TO:<john_%WD_RELDIR%@home.com>will "translate" to
TO:<john_subdir1_subdir2@home.com>
Using a File with email addresses
Use a Plain Text Editor!
The files with email addresses should be "plain text". Use an editor like Notepad to create and modify them.Word processors, like Microsoft Word, should not be used!
You can also have the list of addresses in a plain text file. Enter the addresses exactly like you would in the email settings window, one address per line:
TO:John Doe<john@home.com> CC:<me@home.com>
And you enter the full path to the file with email addresses in the "Send Email To" edit box of the email plugin with an @ prefix:
@C:\Email\AddressList.txt
You can also use variables like described above in those email addresses.
Flexible Address File Location
If you want to send emails to different people, depending on where the new file is found, you can put the files with addresses inside the monitored directory and sub-directories itself. Make sure these files all have the same name (for example EMAIL.TXT), and enter this name in the "Send Email To" edit box with a @@ prefix:
@@email.txt
When the file C:\MonitoredDirectory\Subdirectory\NewFile.txt is detected, the email plugin will load the addresses from C:\MonitoredDirectory\Subdirectory\email.txt.
When the file C:\MonitoredDirectory\AnotherSubdirectory\NewFile.txt is detected, the email plugin will load the addresses from C:\MonitoredDirectory\AnotherSubdirectory\email.txt.
If the email.txt file is not found in the directory with file activity, and you didn't enter any other email addresses to use, no email will be sent.
If you want the email plugin to look for the email.txt file in "higher" directories when it isn't found, add an exclamation (!) before the filename:
@@!email.txt
In this case the email plugin will try the following files when an event in directory C:\Monitored\Sub1\Sub2 is detected:
C:\Monitored\Sub1\Sub2\email.txt C:\Monitored\Sub1\email.txt C:\Monitored\email.txt C:\email.txt
If you do not want to have these address files inside the monitored directory itself, you can "redirect" them to another directory that mirrors the structure of the monitored directory. Enter it in the "Send Email To" box like this:
@@C:\MirroredDir@email.txt
When the file C:\MonitoredDirectory\Subdir\NewFile.txt is detected, the email plugin will read the address list from the file C:\MirroredDir\Subdir\email.txt.
Subject Override
When you use a file with email addresses you can also set the email subject in this file. This subject will "override" the subject you have entered on the main window of the email task. To override the subject enter the following 2 lines at the bottom of the file, after all email addresses.
[subject] subject=Detected file: %WD_FILE%
You can use Environment Variables in this subject, please make sure to enter them in UPPERCASE and to surround them with %PERCENTAGES%.
Message Body Override
When you use a file with email addresses you can also set the email body in this file. This body will "override" the message body you have entered on the main window of the email task. To override the message body, create a section like this at the bottom of the file, after all email addresses:
[body] bodymax=5 body1=Dear customer, body2=We detected the new file %WD_FILE%. body3= body4=Best Regards, body5= Your File Watcher Team.
The "bodymax" entry tells how many body-lines to read (5 in the example above). Follow this entry with body1, body2, body3.... lines.
You can use Environment Variables in the message body, please make sure to enter them in UPPERCASE and to surround them with %PERCENTAGES%.
When you override both the message body and the message subject, it doesn't matter if the [subject] or the [body] section comes first. Just make sure they are after the list of email addresses.