The send mail task can be used to send emails from your Zoho Creator Application. For example, you can invoke the "send mail" function from Form Actions -> on add -> on success script to send mail when a new record is successfully added to the database. To avoid spam email messages, if the From: address is not a zoho.adminuserid or zoho.loginuserid, the To: address can only be zoho.adminuserid and the sendmail task cannot have any CC: or BCC: address. To overcome this limitation, Zoho Creator allows you to add Verified Email Addresses, than can be used as the From or To email address.
You can also directly specify the address in the To: field within quotes, for example "firstname.lastname@example.org", if the to address remains the same for all the records. To send mail to the email ids specified in each record, use the input.<field_name_of_type_email>, which will replace the value of the email id in each record. The subject and message fields can be customized to suit the user requirements. Again, the input.<field_name> can be used to substitute the value of the record.
- If the From address is not zoho.adminuserid, zoho.loginuserid or a verified email address, the To address can only be zoho.adminuserid or a verified email address, and the send mail task cannot have addresses in Cc and Bcc.
- Using variables in From and To:
- If the From address is a variable To address is not zoho.adminuserid or a verified email address, a warning will be displayed upon saving this script. When this script’s execution begins, the task will fail if the variable holds an email address other than zoho.adminuserid, zoho.loginuserid or a verified email address.
- If the From address is not zoho.adminuserid, zoho.loginuserid or a verified email address, and if the To address is a variable (that holds an email address):
- If Cc and Bcc are not included, a warning will be displayed upon saving this script. When this script’s execution begins, the task will fail if the variable holds an email address other than zoho.adminuserid or a verified email address.
- If Cc and Bcc are included, an error will be displayed.
- Send Mail Tasks added from June 25th, 2018 onwards will not support file attachments exceeding 15 MB. If the attachments exceed this limit, the emails will be delivered without them. Existing Send Mail scripts having more than 15MB of attachments will work as usual without any breakages.
From : <string expression>
To : <string expression>
Subject : <string expression>
Message : <string expression>
- To- the mail recipient
- From- the sender
- Subject - the text you want to display in the message subject
- Message- the text you want to display in the message body
- <string expression> - deluge expression evaluating to valid email address in case of From and To and any valid string in case of subject and message. subject and message are optional parameters. To know in detail about the expressions in Deluge, refer to Expressions.
- If your Form is accessed by users without logging in to Zoho Creator, the variable zoho.loginuserid will be set as “Public”. As “Public” is not an email address, the send mail action fails to execute.
You can configure to send e-mail message with form data either from the Form GUI or by adding Deluge Script with the Send mail task.
- To configure email notifications from the Form GUI, refer the topic, Configure email notifications from GUI. The email notifications configured from the Form GUI will be displayed as a script in the Form Actions -> on add -> on success block of the Script tab.
- To configure email notifications with form data by adding Deluge Script, use the input.formdata variable in On Add -> On Success or On Edit -> On Success script.
Steps to add the Send mail script using Script Builder:
- Select the Script tab.
- Select the required Form from the drop down in the page header.
- Select the Form action to invoke the script. For example, if you want to send mail when a record is submitted, select the form action on Add -> On Success.
- Next, select the Deluge task that needs to be executed. To send mail, drag-n-drop the send mail task to the editor area.
- The screen shot below shows the deluge task added to the editor area.
On clicking the Edit button in the script, the Send Mail screen is displayed.
- Specify the From, To, Subject and Message in the Send Mail screen.
- To send mail with formdata, specify the message as shown in the below format selecting the Rich text tab.
- Click Done to update the configurations to the script builder.
- Click Save Script to save the script.
Now, when a record is submitted, the configured email is sent to the specified To address with the Form data. A sample format of the email is shown below.
You can include the record summary template in your send mail task configured in the Form Actions -> On Success block . If Include Template check-box is selected, the record templates created for the form will be displayed as a list below this option. You can select the required template and choose to send it as an inline content or as PDF attactments. If you have not created any custom record templates, use the Default Template that displays the form data in a simple table format.
The CEO of a company wants to address all the new employees who have joined after certain date say, '10-jun-2007' . We have to mail all these new employees. Lets see how we can achive this.
- Form 'Employee' has the following fields: Name, Qualification, EmailID, TeamName, JoinDate
- Write on add -> On success script, as given below:
for each x in Employee [JoinDate >'10-Jul-2007']
To : x.EmailID
From : zoho.adminuserid
Subject : "Meeting at 6:pm tomorrow"
Message : "As our CEO wants to address the new employees, you are requested to attend the meeting.
- for each x in Employee [JoinDate > '10-Jul-2007'] - Fetches the records from the Employee form with the given criteria and iterates over each record, to send mail to the EmailID of each record. Here 'x' is the instance variable that will represent a single record in each iteration.
- sendmail - The deluge function to send mail
- x.EmailID - Refers to the emailid of each record
To send a link/url in your e-mail message, the actual link must be specified within the <a href> html tag and within single quotes, as shown in the sample below. The code is added to On Add -> On Success section.
To : zoho.loginuserid
From : zoho.adminuserid
Subject : "sending links in e-mail messages"
Message : "Please refer the following links :
"<a href=' http://www.company.com/files/att1.pdf '>PDF1</a>" +"<a href=' http://www.company.com/files/att2.pdf '>PDF2</a>")
To send only specific field values in your e-mail, use the input. variable in the send mail task. For example, you have 3 fields (Name, Age, Email), and in the email message you want to send only the Name and E-mail field values. The format for the same will be,
To : zoho.loginuserid
From : zoho.adminuserid
Subject : "Order Confirmation"
Message : "Name : "+input.Name+"Email : "+input.Email
We have an uninstall form with options "Dont Need it", "Not satisfied with the service" and "Temporary Uninstall" added as decision fields. Before uninstalling the app, a customer needs to fill in this form with his selected options.
Screenshot displaying the uninstall form with selected options
Upon submitting the form, a mail is generated to the app owner with the options he has chosen.
Screenshot displaying the mail content
This can be achieved by adding the following code in the On Add -> On Success section of the form:
//declare and iterate a variable to store the selected options
tempstr = "";
if(input.Dont_need_it == true)
tempstr = tempstr + "<br />Dont Need it";
if(input.Not_satisfied_with_the_service == true)
tempstr = tempstr + "<br />Not satisfied with the service";
if(input.Temporary_Uninstall == true)
tempstr = tempstr + "<br />Temporary Uninstall";
//add send mail task to send a mail with selected options
To : zoho.adminuserid
From : zoho.loginuserid
Subject : "Test"
Message : "<p>My reasons for uninstalling the app are:</p>"+ tempstr