Send an Email
This is one of the Additional Actions supported by WatchFTP and typically sends an email for each downloaded file.
- Complete the fields using the variables below in the message Subject and Body
- Click SMTP Server to enter your SMTP Server settings
Subject: The subject for your email. You can use variables (see below) that will be replaced at runtime.
Message Body: The message body of this email. You can use variables (see below) that will be replaced at runtime.
To, CC, BCC...: Enter one or more email addresses that will receive this message. Multiple addresses are separated by commas.
When "One email per download" is set, you can instead enter a filename preceded by an @ in those fields, for example @C:\EmailList\email.txt.
This file allows you to send emails to different people depending on the FTP directory where files are detected.
The syntax of this file is described here.
One email per download: Send an email for each downloaded file. If this option is not selected, only a single email is sent for all downloaded files.
Selecting this option also enables the Environment Variables supported by the Start a Batch script action. Note that those variables are surrounded by %percentage% signs, not dollar-signs.
SMTP Server: Enter the settings for your SMTP Server here.
Variables
$DATE$ | Current date. |
---|---|
$TIME$ | Current time. |
$WFILE$ | Windows Filename of the downloaded file. If you did not select One email per download this variable contains the list of the downloaded files and is ignored in the message subject. |
$UFILE$ | The Unix Filename of the downloaded file. If you did not select One email per download this variable contains the list of the Unix filenames and is ignored in the message subject. |
How $DATE$ and $TIME$ are formatted is controlled by the date and time format string, see further down below.
If you selected One email per download, you can also include Environment Variables surrounded by percentage signs.
Repeat Blocks
If you have not selected "One email per download", WatchFTP sends just one email for all downloaded files. Inside the message body of this email you can write a "repeat block" that will be repeated for each file. Inside those repeat blocks you can also use Environment Variables that will be replaced by correct values for the "current" file.
For a Repeat-Block example, see HTML Email below.
Send email to different people depending on the FTP directory
"One email per download" is set!
In the "To", "CC" and "BCC" edit box you can enter the full path of a special text file that determines
to whom the email is sent. This file name must be prefixed with an @ sign, for example:
@C:\Temp\EmailList.txt
The file must contain lines with a matchpattern, followed by a semicolon and one or more email addresses separated by a comma.
Here is an example of such a file:
(matches everything)
as the last pattern!
*/incomingorders/*;sales@example.com,helpdesk@example.com */failedorders/*;helpdesk@example.com *;support@example.com
When an email is sent, the full path of the detected file (for example
UPPER/lowercase is ignored while matching and you can use the wildcards * (matches 0 or more characters) and ? (matches exactly 1 character).
HTML Email
If you want to send nicely formatted emails, you can let WatchFTP send them in HTML format. To make sure WatchFTP recognizes it should enable html, make sure your message body starts with <html> (in lower case).
Example:
<html> <body bgcolor="#E6E6FA"> Hello!<br><br> #REPEAT# The FTP file <b>$UFILE$</b> has just been downloaded to <b>$WFILE$</b> (%WF_FILE_SIZE_KB% kilobytes).<br> #ENDREPEAT# </body> </html>
Date and Time Format
Her you can enter a format string to control how the $DATE$ and $TIME$ strings are formatted.
As an example, enter %#m/%d/%Y for month/day/year. The # (%#m in the example) removes leading zeroes.
The table below shows the list of formatting codes you can use.
%a | Abbreviated weekday name |
%A | Full weekday name |
%b | Abbreviated month name |
%B | Full month name |
%c | Date and time representation appropriate for locale |
%d | Day of month as decimal number (01 – 31) |
%H | Hour in 24-hour format (00 – 23) |
%I | Hour in 12-hour format (01 – 12) |
%j | Day of year as decimal number (001 – 366) |
%m | Month as decimal number (01 – 12) |
%M | Minute as decimal number (00 – 59) |
%p | Current locale's A.M./P.M. indicator for 12-hour clock |
%S | Second as decimal number (00 – 59) |
%U | Week of year as decimal number, with Sunday as first day of week (00 – 53) |
%w | Weekday as decimal number (0 – 6; Sunday is 0) |
%W | Week of year as decimal number, with Monday as first day of week (00 – 53) |
%x | Date representation for current locale |
%X | Time representation for current locale |
%y | Year without century, as decimal number (00 – 99) |
%Y | Year with century, as decimal number |
%z, %Z | Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown |
%% | Percent sign |