Send Mail

Send mail

Table of Contents

Overview

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 the on success workflow section to send mail when a new record is successfully added to the database.

You can also directly specify the address in the To: field within quotes, for example "john@zylker.com", if the to address remains the same for all the records. To send an email to the email addresses specified in each record, use the input.<field_name_of_type_email>, which will replace the value of the email address 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.

Note:

  • If the From address is not zoho.adminuseridzoho.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.adminuseridzoho.loginuserid or a verified email address.
    • If the From address is not zoho.adminuseridzoho.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.

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:

  • If your Form is accessed by users without logging in to Zoho Creator, the variable zoho.loginuseridwill be set as “Public”. As “Public” is not an email address, the send mail action fails to execute.

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 an 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 Success workflow 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

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 the selected options.

Upon submitting the form, a mail is generated to the app owner with the options he has chosen. This can be achieved by adding the following code in the On Success workflow 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
sendmail
(
To : zoho.adminuserid
From : zoho.loginuserid
Subject : "Test"
Message : "<p>My reasons for uninstalling the app are:</p>"+ tempstr
)

Example 5

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.

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocreator.com