This tutorial will demonstrate how to create a Task and add necessary Triggers and Actions to constantly watch files and automatically send emails. We will use Automation Workshop to automatically email new files in a folder.
Then, at the end we will look at how to attach a folder automatically to the email using a built-in zip archiver.
Overview
Let us assume that once a week a report file is put into C:\Reports\
folder in Adobe Acrobat .pdf
format. In contrast to other file types copied into C:\Reports\
folder, all .pdf
reports have to be sent over email.
As we can see, the Task at hand involves two parts:
- First, we need to watch files of particular type, namely, files with a
.pdf
extension. - And, second, whenever a File Watcher detects such a file in
C:\Reports\
folder, it needs to send an email with the watched file in attachment.
Create a Task
Let us begin with creating a Task. Click on the New Task button. This will open the Task Wizard—an easy to use tool for Task creation in Automation Workshop.
The automated task will send an email when a new file is created in a folder. It will only send .pdf
files from the specified folder.
Add a Watcher
In order to watch files in folder C:\Reports\
we will need to add a File Watcher. In Automation Workshop File Watcher functions are included in a Trigger called File & Folder Watcher. Click on the Add, and choose File & Folder Watcher from the list of triggers.
Configure the File Watcher
To send an email when a file is added to a folder, we will need to watch files as they appear in a particular folder. Click the Browse button and choose C:\Reports\
folder. The File Watcher will watch files only in this folder (and, optionally, also its subfolders).
Second, when watching files in C:\Reports\
folder, we only need to execute the Task when the File Watcher detects a file matching our criteria. And since we are specifically looking for all Adobe Acrobat files (files with .pdf
extension), we need to use a filter.
We will need to use the Include mask to watch files with a specific extension.
- The proper mask is
*.pdf
that reads—all PDF files. - This way the File Watcher will automatically exclude other files that do not end with a
.pdf
extension. - See more information on file masks.
Now, after the File Watcher is configured, let us configure the email sending part of the Task. Click OK to save File & Folder Watcher configuration and go to the Actions.
Configure automated email
How to add and configure email sending with the watched file in attachment? First, we need to add appropriate Action to send files. From the Actions tab, click on the Add button to open the list of available Actions. Choose Send Email Action from the Email category.
After entering From and To addresses as well as email subject and text, we need to attach the file watched by the File & Folder Watcher Trigger. Select the Attachments field, and click on the Variable Wizard button.
In this case we need to tell the Send Email Action to attach the file which has triggered the File & Folder Watcher. In other words, we need to fill the Attachment field with the filename from the File & Folder Watcher Trigger.
Select File & Folder Watcher from the Trigger category and use the default preset Full path and filename value.
Now, the Attachment field contains a Filename variable. It means that each time the Send Email Action tries to send an email, it will automatically attach the file, which initiated the automated Task by appearing in C:\Reports\
folder.
Finalizing the Task
After adding Send Email Action, the Wizard presents you with Run As settings as well as Reports for both successful Task execution and failure.
The final step is giving the Task a name, for example Auto send email with attachment
. An optional description of the task can help you describe the purpose of the task. Describe it in your own words.
Conclusions
We've just created a Task that contains the File & Folder Watcher Trigger and Send Email Action. The File & Folder Watcher is configured to watch C:\Reports\
folder and execute the Task as soon as a new .pdf
file appears in it.
When executed, the Task launches the Send Email Action. The Send Email Action requests the path and file name of the watched file from the File & Folder Watcher Trigger. In other words, we are attaching the same file, which appearance initiated the Task itself.
Then the Send Email Action sends an email to the specified address with the watched file in attachment. The Task successfully finishes and is only triggered again when another new .pdf
file appears in C:\Reports\
folder.
Congratulations! You have just created your own auto mail sender app without writing a single line of program code.
Try it out by yourself! Download a free trial version of Automation Workshop and start sending automated email with attachment in minutes.
Comparison to PowerShell
What are pros and cons comparing the Automation Workshop app with the PowerShell script? While PowerShell scripts may seem to be easy to implement and deploy, in the long term they require maintenance by a qualified PowerShell programmer.
Compare pros and cons for both solutions, and decide which one fits you the best.
Features | Automation Workshop | PowerShell |
---|---|---|
Automated solution ¹ | ✔️ | |
Easy to customize | ✔️ | |
Can be triggered by new files | ✔️ | |
Can be launched from a batch file | ✔️ | ✔️ |
Short time to deploy | ✔️ | ✔️ |
Can attach a whole folder | ✔️ | |
Graphical user interface | ✔️ | |
Event logs | ✔️ | |
Error logs | ✔️ | |
Email notifications | ✔️ | |
Windows Event Log support | ✔️ | |
No coding skills required | ✔️ | |
A steep learning curve | ✔️ | |
FTP, SFTP, Cloud support | ✔️ | |
Latest security standards SSL/TLS ² | ✔️ | |
Backup/restore in the case of disaster | ✔️ | |
Low upfront cost | ✔️ | |
High maintenance cost | ✔️ | |
High Return on Investment | ✔️ | |
Free of charge ³ | ✔️ | ✔️ |
¹ Did you know that Automation Workshop can execute PowerShell scripts natively? See all Execute Script Action features.
² See the Microsoft official documentation · Microsoft.PowerShell.Utility Send-MailMessage · The Send-MailMessage cmdlet is obsolete. This cmdlet does not guarantee secure connections to SMTP servers.
³ Free of charge when used for personal non-commercial purposes.
Further improvements…
- To send a whole folder as an email attachment, use Zip Files Action. It goes as follows:
- create a zip file from individual files… basically compressing the folder;
- send the whole folder (zipped) as an email message attachment.
- To send different files and a different email message to the email address from a list, use a mail merge like approach.
- Make a document library from the sent emails, similarly to the Sent Items in your Inbox · Move the PDFs to the archive folder.
- Or save emails using a built-in save option · Save email to .EML file instead of sending.
Configure SMTP server
To send email, Automation Workshop needs an outgoing mail server. SMTP protocol is industry standard for email sending. The SMTP mail server can be configured in the Server tab or in the Automation Workshop Options.
If you don't know the server name, port and other parameters, copy them from your favorite email app. To test and debug connection to the server, follow this troubleshooter.
Help at your fingertips…
If you have any questions, please do not hesitate to contact our support team.