sgapiEmailSend

Important Update to Custom Scripting

The CustomScript Action now supports the LUA programming language. Visit our NEW Lua Scripting Resources!


  1. New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
  2. As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
  3. In the long term, Legacy Custom Scripting Actions will be switched to read-only. The exact date on this is to be determined; we will send notifications well ahead of time.

This function constructs and sends an email at the runtime of your custom script.

sgapiEmailSend(%%to, %%toName, %%from, %%fromName, %%subject, %%textBody, %%htmlBody, %%bcc, %%mailReplyTo, %%type, %%attachments)

Parameters*

  • %%to - The recipient's email address.
  • %%toName - The recipient's name.
  • %%from - The sender's email address.
  • %%fromName - The sender's name.
  • %%subject - The subject line.
  • %%textBody - The plain text email body.
  • %%htmlBody - The html formatted email body.
  • %%bcc - bcc email address (can be an array).
  • %%mailReplyTo - Send replies to email address.
  • %%type - The type of email to send "text" or "html."
  • %%attachments - Email attachments (can be an array).

*All parameters must be present

Example

The below script will send a response confirmation to the respondent. The script is run and the email is sent when the page is displayed. Logic can be set up with in the script or on the logic tab within the application to conditionally run the action and send the email.

%%to = sgapiGetValue(7);
%%toName = sgapiGetValue(1);
%%textBody = '';
%%bcc = '';
%%htmlBody = "Thank you for completing the survey. Your response is appreciated<br />We will be in touch shortly!.<br /><br /> Thanks,<br />Your Company";

sgapiEmailSend(%%to, %%toname, "your.company@company.com", "Your Company", "Your Assessment Results", %%textBody, %%htmlBody, %%bcc, %%to, "html");