CREATEMAIL        Create an e-mail message

Top  Previous  Next

Syntax:

CREATEMAIL

[ from name ] [ from email ] [ subj ] [ body ] [ attach ] [ options ]

Arguments:

[ from name ]

Variable or string defining the optional name of the sender; this argument is required in the command even if you do not specify a sender - in this case be sure to specify an empty string (e.g., "").

 

[ from email ]

Variable or string defining the e-mail address of the sender.

 

[ subj ]

Variable or string defining an optional subject line for the e-mail message; this argument is required in the command even if you do not have a subject line - in this case be sure to specify an empty string (e.g., "").

 

[ body ]

Variable or string defining the body of the message.

 

[ attach ]

Variable or string defining the file name of an optional attachment for the e-mail message; this argument is required in the command even if you do not have an attachment - in this case be sure to specify an empty string (e.g., "").

Options:

/nocrlf

Ignore embedded \n and/or \r carriage control

 

/htmlbody

Specify an HTML body for the email. Use this to create a pretty message using HTML.

 

/embed

Embed content in the email to be linked to by the HTML body. The /embed option creates embedded content that may be accessed from the html body with incrementing urls starting with the form

cid:CID_0000000001@Robo-FTP

And counting up with each one added. This option may occur more than once or it may contain a pipe separated list of files.

 

For new scripts, we recommend using the EMAIL script command instead, which supersedes both the CREATEMAIL and SENDMAIL commands.

 

This command builds an e-mail message to be sent using the SENDMAIL command. The recipient of a message is specified in the SENDMAIL command.

 

All of the arguments to this command are required; however the [ from name ], [ subj ], and [ attach ] arguments may be empty strings.

 

The [ body ] variable provides for a simple message body. The message body cannot be longer than 2040 characters. Use an attachment file to send larger messages.

 

Carriage control within the message body (i.e., a \n to insert a line feed in the message and a \r to insert a carriage return) is permitted unless the /nocrlf option is specified. Use of the option /nocrlf suppresses the recognition of the \n and \r sequences. This is useful if you are e-mailing file names in the message body that may include either of these two sequences. When using the /nocrlf option the %crlf internal variable is still available for adding line breaks to your email body text.

 

Consider the following example where an e-mail message is created with an attachment.

 

SET from = "Acme Widget Co. Sales"

SET email = "[email protected]"

SET subj = "Thanks for your order!"

SET body = "An invoice is attached"

SET attach = "c:\sales\customer.inv"

CREATEMAIL from email subj body attach

 

The following example results in a message without an attachment.

 

SET from = "Acme Widget Co. Sales"

SET email = "[email protected]"

SET subj = "Thanks for your order!"

SET body = "We appreciate your business."

CREATEMAIL from email subj body ""

 

The following example results in a two line message body.

 

SET body = "Line 1.\r\nLine 2."

 

Warning: By default, the MS Outlook mail reader "helps" format plain text messages by not displaying "extra" line breaks. This can essentially ruin all the hard work you put into formatting emails sent by Robo-FTP. You can defeat this feature by understanding what causes Outlook to remove line breaks.  Outlook will not show line breaks if a line goes over 40 characters in length unless the line ends with a period, question mark, exclamation, tab, or at least three spaces or begins with a tab or at least two spaces. Obviously this is subject to change if Microsoft changes Outlook.

 

Only a single file may be be attached but you can use the ZIP command to combine multiple source files into a single archive and send that instead:

 

ZIP "attach.zip" "c:\web_dev\index.html" /create

ZIP "attach.zip" "c:\web_dev\style.css"

ZIP "attach.zip" "c:\web_dev\script.js"

ZIP "attach.zip" "c:\web_dev\logo.gif"

ZIP "attach.zip" "c:\web_dev\map.gif"

ZIP "attach.zip" "c:\web_dev\storefront.jpg"

SET body = "Hello Team,   " + %crlf + %crlf

SET body = body + "The current version of the web page is attached." + %crlf + %crlf

SET body = body + "Regards,   " + %crlf + "John Smith (via Robo-FTP)"

CREATEMAIL "j.smith" "[email protected]" "Home page" body "attach.zip"

 

The CREATEMAIL command does not support using wildcards to specify an attachment. If you need to send an attachment where the name of the file is not known ahead of time, you can accomplish this using the GETFILE command, as in the following example.

 

GETFILE "C:\PATH\TO\FILES\*.txt" ;; returns the first file that matches the criteria

CREATEMAIL "j.smith" "[email protected]" "Home page" "Message body." %nextpath

 

Important

To cut down on spam, some mail servers now require that the email address in the FROM line match an existing mailbox on the server. If your mail server returns an error when you call the SENDMAIL command, please check the FROM email address. Also, to fight botnets, some Internet Service Providers are now blocking outbound traffic on port 25 by default so you may need to contact your network administrator or ISP before using an external mail server.

 

Consider the following example for building an e-mail message that will contain embedded images:

 

SET email_subject = "Example"

SET html_body = '<html><body><img src="cid:CID_0000000002@Robo-FTP" />'

SET html_body &= '<img src="cid:CID_0000000001@Robo-FTP" /></body></html>"  

SET text_body = "Contents for email clients that can't display HTML."

CREATEMAIL from_name from_email_address email_subject text_body "" /htmlbody=html_body /embed="image_big.jpg" /embed="image_small.jpg"  

 

In the example above, note that the src attribute for the img tags contain a number. This number must correspond to the order that the images were given in the CREATEMAIL command. That is, the correct src attribute for displaying the first image specified in the CREATEMAIL tag is: src="cid:CID_0000000001@Robo-FTP". The correct src attribute for displaying the second image specified in the CREATEMAIL tag is: src="cid:CID_0000000002@Robo-FTP".

 

Consider the following alternate syntax for adding a embedded images:

 

CREATEMAIL from_name from_email_address email_subject text_body "" /htmlbody=html_body /embed="image_big.jpg|image_small.jpg"

 

In the example above, instead of specifying multiple images with multiple "/embed=" options, a single "/embed=" option is used to specify multiple images, with each image separated by a "pipe" character (|). This alternate syntax is functionally equivalent to the command in the first example, but is particularly useful for scripts that build e-mails which contain a variable number of embedded images.

 

Related command(s): EMAIL, SENDMAIL, GETMAIL, MAILTO

See also: %crlf, Sending and Receiving E-mail, Sending SMS text messages