Method: SendEmail( … )

Superseded by the SEND.MAIL Action Command

Will send an email to 1 or more recipients. All of the parameters on this method with the exception of format can use templated content in the same way as the Make() method. By default emails will be sent with content in plain text format unless specified that content should be html.

Dependencies: SMTP Server

It must be configured what SMPT server to use for sending emails by using the SET Command. The SMTP server must be defined in the following way, and assigned to the system parameter SMTP.

host=smtp.gmail.com;port=587;username=user@gmail.com;password=mypwd

Syntax

SendEmail( string from, string recipients, string subject, string body ,string format = "text", string cc = null, string bcc = null )

Example 1

Below first shows a very simple example, and then a more advanced example with multiple recipients looked up from a Data Source, Message content looked up from a global variable named $Message, and content in html-format as well as a secret bcc recipient.

// simple example SendEmail( "info@perfion.com", "person@gmail.com", "My Subject", "My body message" ); // example with more recipients, in html format, and lookup of content SendEmail( "info@perfion.com", "{Recipient1},{Recipient2}", "My Subject", "{=$Message}", format: "html", bcc: "secret@gmail.com" );

Example 2

Below shows an example of an Action with 2 Commands. First Setting up what SMTP server to use for sending emails (by looking up the actual setting) and assigning a message to a global variable named $Message. Next Executing a script using the SendEmail() method.