{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":39219,"path":"platform-administration/r_MailScriptAPI.md","title":"Mail script variables","bundle":null,"doc_type":null,"release":"australia","body":"\n# Mail script variables\n\nCertain variables are available when processing mail\\_script scripts.\n\nFor examples of mail scripts, see [Example scripting for email notifications](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/r_ExScptEmlNtfn.md).\n\n<table id=\"table_psj_g1q_rq\"><thead><tr><th>\n\nVariable\n\n</th><th>\n\nObject Description\n\n</th></tr></thead><tbody><tr><td>\n\ntemplate\n\n</td><td>\n\nHandles printing from the mail script to the email message.\n\n `template.print(\"message\"); //outputs message to the email body.`\n\n `template.space(\"number of spaces\"); //outputs spaces to the email body.`\n\n</td></tr><tr><td>\n\nemail\\_action\n\n</td><td>\n\nGlideRecord object for the email notification \\(sysevent\\_email\\_action\\).\n\n</td></tr><tr><td>\n\nevent\n\n</td><td>\n\nGlideRecord object for the event that fired the notification \\(sysevent\\).\n\n</td></tr><tr><td>\n\nemail\n\n</td><td>\n\nEmailOutbound object\n\n Available methods:\n\n-   `addAddress(String type, String address, String displayname):` type can be cc or bcc.\n-   `setFrom(String address):` override the sender address.\n-   `setReplyTo(String address):` override the reply to address.\n-   `setSubject(String subject):` override the subject of the message.\n-   `setBody(String message):` override the body of the message.\n\nThe email address that is passed by `setFrom` and `setReplyTo` needs to be in a valid form such as `helpdesk@sn.com` or `Display Name <helpdesk@sn.com>`. If the email address includes a 'Display Name', then that value overrides the instance's display name.\n\n For more information, see [GlideEmailOutbound - Scoped](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/c_GlideEmailOutboundScopedAPI.md).\n\n</td></tr></tbody>\n</table>**Parent Topic:**[Scripting for email notifications](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/c_ScriptingForEmailNotifications.md)\n\n**Related topics**  \n\n\n[Include mail scripts in email notifications]()\n\n[Example scripting for email notifications]()\n\n[Useful attachment scripts]()\n\n"}}