Monitor FTP sites with WatchFTP Monitor FTP sites with WatchFTP


  screenshot of this window

Send an Email

This is one of the Additional Actions supported by WatchFTP and typically sends an email for each downloaded file.

  1. Complete the fields using the variables below in the message Subject and Body
  2. 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

This will only work when the option
"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:

Always use *
(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 /some/root/incomingorders/order-1234.txt) is matched against each matchpattern and the email will be sent to the listed emails of the first pattern that matches.
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.

%aAbbreviated weekday name
%AFull weekday name
%bAbbreviated month name
%BFull month name
%cDate and time representation appropriate for locale
%dDay of month as decimal number (01 – 31)
%HHour in 24-hour format (00 – 23)
%IHour in 12-hour format (01 – 12)
%jDay of year as decimal number (001 – 366)
%mMonth as decimal number (01 – 12)
%MMinute as decimal number (00 – 59)
%pCurrent locale's A.M./P.M. indicator for 12-hour clock
%SSecond as decimal number (00 – 59)
%UWeek of year as decimal number, with Sunday as first day of week (00 – 53)
%wWeekday as decimal number (0 – 6; Sunday is 0)
%WWeek of year as decimal number, with Monday as first day of week (00 – 53)
%xDate representation for current locale
%XTime representation for current locale
%yYear without century, as decimal number (00 – 99)
%YYear with century, as decimal number
%z, %ZEither the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown
%%Percent sign