WatchDirectory Forum
watchDirectory forums >> Plugins >> Muliple email messages based on subfolder?

Message started by dbortunk on Mar 23rd, 2009 at 10:09pm

Title: Muliple email messages based on subfolder?
Post by dbortunk on Mar 23rd, 2009 at 10:09pm
Is it possible to have multiple email subject lines or bodies based on subfolder? I have 9 subfolders in every root folder and the subject needs to be different depending on which folder the file is dropped into. Is this possible without creating a task for each folder?

Title: Re: Muliple email messages based on subfolder?
Post by Gert on Mar 24th, 2009 at 9:38am

There are 2 ways for that. The easiest, but maybe a bit more work, is to use the "SubTask" plugin:
Configure multiple email subtasks, and use a proper "mask" so only one of them will run for detected files.
So, the mask for Subtask 1 could be "*\Subdir1\*", Subtask2 would have "*\Subdir2\*".

Another way to do this (here you can only make the subject and recipients depend on the subdir) is to use files with email addresses as described here:
One undocumented feature of those files is that you can change the subject there. At the bottom (after the email addresses) enter the following 3 lines:

subject=The subject I want to use

Title: Re: Muliple email messages based on subfolder?
Post by dbortunk on Mar 24th, 2009 at 6:08pm
right but what happens in the case you have something like this

Root Folder

So I want it to monitor the root folder for any files placed in subfolders (Files are only placed in folder1, 2 ,3 in each vendors folders). Then based on the vendor subfolder that the file is dropped into, send an email specific to that vendor (which is where the customized subject line comes into play). I understand how you could do it if you are monitoring the folders in the inside like folder1 can this be done without creating a task for each vendor?

Title: Re: Muliple email messages based on subfolder?
Post by Gert on Mar 25th, 2009 at 7:52am
Yes, that can be done.
first method
If you use the first method (using the subtask plugin), you would let the task (this is not the same as the subtask) monitor
C:\Root Folder
including sub-directories.
Now create 2 SubTasks, both using the email plugin. For each subtask you have 100% control over the recipient, subject and message body. The "trick" is to enter vendor specific masks ("only run this subtask for files matching") on the subtask settings - ).

So in your case, Subtask1 would use
(that would match all files having "vendor1" somewhere in their complete pathname).
Subtask2 uses

second method
create a task (email plugin) that monitors
C:\Root Folder
including sub-directories.

Inside the "Send Email To" box, do NOT enter an email address, but enter
(at at exclamation mark)
This tells the task to look for a file with email addresses called email.txt in the same directory where the newly detected file is found. If this file is not found there, the task will look one directory higher (all explained here: ).

Now create the file "C:\Root Folder\Vendor1\email.txt" using notepad. Enter the following lines:

Code (]TO:John Doe<>

subject=Hello Vendor 1!

Likewise create the file "C:\Root Folder\Vendor2\email.txt"

what method to use
The first method (using subtasks) gives you most flexibility. You can have a different message body, for example. The second method (advanced addressing using @@!email.txt)  is fastest to setup.

At runtime there is no real difference in performance as both these methods use one "new file detection" engine.

Does this better explain?

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.