Creator Help

Send mail

Overview

The Sendmail task can be used to send emails from your Zoho Creator application. For example, you can invoke the sendmail 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.

You can also directly specify the address in the To: field within quotes, for example "test@zoho.com", 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.

Syntax

sendmail
[
From : <string expression>
To : <string expression>
Subject : <string expression>
Message : <string expression>
]

where,

  • 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.

Note:

  • The email sent will have the email id of the application owner or the email id of the login user, as the From address. 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.
  • 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. 

Using Script Builder

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.

  1. 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.
  2. 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.

Include record summary in send mail

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.

Examples


Example 1

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.

  1. Form 'Employee' has the following fields: Name, Qualification, EmailID, TeamName, JoinDate
  2. Write on add -> On success script, as given below:

for each x in Employee [JoinDate >'10-Jul-2007']
{
sendmail
{
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.
<br>Thanks"
)
}

Code Explanation

  • 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

Example 2

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.

sendmail
(
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>"
)


Example 3


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,

sendmail
(
To : zoho.loginuserid
From : zoho.adminuserid
Subject : "Order Confirmation"
Message : "Name : "+input.Name+"
" +"Email : "+input.Email
)


Example 4

To use the Email ID field in Form A as the “To Address” of the send mail task in From B, refer sample application Subscribe to Newsletter.

Related Topics

Send mail to selected records in a view using Custom Actions

Top