HiTek Software Home
When new files come into folder, send email and attach these files
Date Updated  -  07/22/2007
User question:  When new files are added to a directory, I would like to automatically create and send an email with those files as attachments.  Also, the files need to be moved out to a backup folder after the email has been sent.

You would have to create 5 tasks: File Monitor task, Email task, Copy task, Delete task, Chain task

1) File Monitor task -
Dir to monitor = c:\data_folder
Filename = (leave blank. This will monitor all files)
Task To Run = None
Options = Run task if File exists 

2) Email task
In the attachment field, use
This will attach all files from the c:\data_folder to the email

3) Copy task
Source Dir = c:\data_folder
target Dir = c:\backup_folder
Filename = (leave blank - this will backup all files to the c:\backup_folder)

4) Delete task
Source Dir = c:\data_folder
Filename (leave blank - this will delete all files in the c:\data_folder)

5) Chain task (4 steps)

Step 1 - File monitor task
Select Option : If exit code = 0, Go to Step 100. This makes sure that if no file(s) are found, then the email, copy and delete tasks are not run.  If file(s) are found then exit code = -100, and steps 2-4 in chain will be run

Step 2 - Email task - default options
Step 3 - Copy task - default options
Step 4 - delete task - default options

6) Schedule the chain task to run at your desired frequency.