Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

MENUMENU

Syntax:

SENDEMAIL(from,to,cc,bcc,subject,body,attachment)

  • from: The email address used as the sender address.
  • to: The To field of the email. One or multiple email addresses (separated by a semicolom).
  • cc: The CC field of the email. One or multiple email addresses (separated by a semicolom).
  • bcc: The BCC field of the email. One or multiple email addresses (separated by a semicolom).
  • subject: The subject of the email.
  • body: The actual text of the email you want to send.
  • attachment (optional): The full path of a file you want to attach to the email.

Remarks:

Before using this command you have to set the SMTP server with the SETEMAILSERVER command.

Return Value:

SENDEMAIL will return “OK” if the email has been successfully sent. If the SMTP server was not previously set wit SETEMAILSERVER it will return an error.
If the operation fails it will return an error code. You may retrieve the return value and execute various operations depending on this value. See Error Handling.

See also:

SETEMAILSERVER
SETEMAILSERVERPORT
Sending emails from a script


Command history:

This command was added in ScriptFTP version 4.5 (released 6/2/2018). Previous versions of ScriptFTP needs to use EXEC to send an email.

Examples:

# Set the SMTP server settings
SETEMAILSERVER("smtp.mydomain.com","me@domain.com","the_password",AUTO)
 
# Send the email
SENDEMAIL("me@domain.com","destination@domain.com","","","this is the subject","this is the email body","C:\Users\Carlos\Desktop\scriptftp_log.txt")