Your scheduled automatic download should be finished by now. But how would you know how it went without physically or remotely logging into your server? Had you used JSCAPE MFT Server, you could have configured it to email you an update. In this post, we'll show you how to set up JSCAPE MFT Server to email you a message along with a file attachment with details about your latest file transfer.
What we're trying to do
You can consider this a continuation of a previous post where we enabled JSCAPE MFT Server to generate a list of freshly downloaded files. That list was stored in a file. We'll now use that file to signal the server when a download has been made. This will entail creating a directory monitor that would detect when that file has changed. Assuming no one else edits that file, a change will only occur whenever a list has been generated unto it, which in turn can only happen as a result of that scheduled download.
1. Create a Directory Monitor for detecting file changes
To create that directory monitor, go to the Directory Monitor node and click Add.
Give that directory monitor a name (e.g. "Download List Monitor") and select the directory that contains the file where that list of downloads will be generated on.
To prevent the monitor from also monitoring subdirectories that may be found underneath that directory, make sure the Monitor Recursively checkbox is unchecked.
You will also want to uncheck the Monitor interval checkbox. This will allow us to activate this monitor on demand instead of letting it run every x number of seconds. The only time we'll need this monitor is after the download has completed, so letting it run on demand can help us save precious computing resources.
Lastly, in the Events panel, uncheck everything except the Monitor File Change check box.
Once you're done, click the OK button.
You should then see your newly created directory monitor. See that "run by trigger" under the Interval column? That means this directory monitor can only be activated by a trigger. In the succeeding section, we'll talk about how to make such a trigger.
2. Create a trigger that will activate the directory monitor
We will now create the trigger that would activate our directory monitor. This will be a time-based trigger, which we'll schedule to run about 12 hours after that scheduled download. Since our download is scheduled to run at 8:30 PM on every first day of the month, we'll set this trigger to run at 8:30 AM the following day. This will give the download ample time to complete.
So now, create a trigger and give it a name (e.g. "Activate Download List Monitor").
Because we want this trigger to run at a predefined schedule, select the Current Time event type. Click Next to proceed.
When you get to the Trigger Conditions window, click the Time Expression button and specify the time when you want this trigger to run. In our case, we'd like it to run at 8:30 AM on every second day of the month. Click OK when done.
Click Next to proceed.
Add a new trigger action.
For this purpose, select the Run Directory Monitor trigger action. As its name implies, this trigger action will run a directory monitor.
When you get to the trigger action parameters, select the name of the directory monitor we created earlier. In our case, that would be "Download List Monitor". Click OK when done.
Click OK to proceed.
Don't forget to click the Apply button once you get to the main screen. This will finalise the trigger creation process.
3. Create the trigger that will send the email.
We're now ready to create the trigger that will be responsible for sending the email notification.
Create a new trigger and give it a name (e.g. "Email Download List").
What we want is a trigger that would fire whenever the file containing that list of downloads has changed. Thus, what we need is the Directory Monitor File Changed event type. Select that and click Next.
Just in case you have several monitors on your server that detect file changes, filter out all other monitors by adding the condition:
MonitorName = "Download List Monitor"
And if you have several files in the directory being monitored by "Download List Monitor", you can likewise filter out other file changes by specifying the file name. Just add the condition: Name = "the name of the file containing the list". Since, in our case, the file is filesdownloaded-moved.txt, then our complete trigger condition would be:
MonitorName = "Download List Monitor" AND Name = "filesdownloaded-moved.txt"
Click Next to proceed.
Add a new trigger action and select "Send Email".
Enter all the necessary parameters for sending that email notification, including the hostname of your SMTP server, the port number, connection type, etc.
In the Body text box, enter the message you want to relay. And then in the Attachment field, browse to the file you want to send. In our case, it's the filesdownloaded-moved.txt, which contains a list of those files that were automatically downloaded the previous night.
Click OK when done.
Finalise the trigger by clicking Apply.
Did you like this post? Perhaps you might want to read these as well:
You might want to read these too
Want to try this out yourself? Download the free, fully-functional evaluation edition of JSCAPE MFT Server now.
We'd love to engage with you on social media. Do connect with us ...