Home > FAQ > Useful Basic Tasks when writing a script > How do I find the window which has the focus?


The SendEmail function sends an email using the SMTP outgoing mail server defined in WinTask Scheduler email notification.


Used to perform notifications, for example if the script fails.


ret = SendEmail(<from>, <to>, <subject>, <message_text> [, <attachments> [, <cc>]])


<from>. string, email address of the email sender.

<to>. string, email address of the recipient.

<subject>, string, subject of the message.

<message_text>, string, body part of the message. The maximum length for the body part as a simple string is 80 characters. For a longer body text, use a file: if the first character of the string is the ! character, the message is the content of the file specified by the filename after this ! character.

<attachments>, optional string, one or several filenames to attach (the ; character is the separator if several files are specified). If the first character is the ! character, the unique filename specified behind this character is used to send all the files which are listed line by line in this metafile.

<cc>, optional string, email addresses that the message should be sent "carbon-copies" to.

Return value

ret, optional integer return value. If the function succeeds, the return value is 0. If the function fails, the return value is a nonzero value (see System Functions Error Codes).


Generate the SendEmail syntax using its wizard: in the Language pane of the WinTask Editor, double-click the SendEmail function name to start the wizard (if the Language pane is not displayed, press F4 or select Insert/Statement menu).

The SMTP mail server settings are defined in Scheduler, Email notification Tab.


'Send a simple email.
info@gmail.com","order@gmail.com","Meeting today","The meeting today is at 8 am")

'Send a longer email witht the body text in a file.
info@gmail.com","order@gmail.com","Read this","!C:\bodymail.txt")

'Send an email with attachments listed in a metafile text file.
'c:\metafileemail.txt for example lists those 4 files
'c:\program files (x86)\wintask\scripts\my_script.src
'The SendEmail line below sends as attached files the 4 files above.
info@gmail.com","order@gmail.com","Test metafile","Please save the attached files","!C:\metafileemail.txt")