Automate a mailer to a set of users

Automate a mailer to a set of users

Requirement

Send season's greetings automatically to all the employees in an organization on the chosen day.

Use Case

In a typical employee management application, the Employees form will track employee details. Sending emails is the official way of communication. Season's greetings can also be sent by email, which can be scheduled to run on specific dates based on the list of holidays entered using the Holidays form.

See how it works

Steps to follow

1. Create two forms with the following details:
Form
Form Link Name
Field Type
Field Name
Field Link Name
Holiday List
Holiday_List
Date
Date
Date
Single Line
Occasion
Occasion
Employee
Employee
Name
Name
Name
Address
Address
Address
Date
Date Of Birth
Date_Of_Birth
Single Line
Department
Department
Email
Official_Email
Official_Email

The Official Email field holds the email address to which the season's greetings will be sent.

2. Add a few records to the Holidays form.
 
3. Create a schedule to run on the dates in the All Holidays List report. Create a schedule based on the date field:
 
4. This schedule will be executed based on the Date field of the Holiday List form. This needs to be executed once on the dates in the All Holidays List report. (The dates may change from year to year, so it is advisable to have a new list every year.)
 
5. Click Add New Action and select Deluge Script. Add the below sendmail Deluge code for triggering the season's greetings for every employee in the All Employees report, and click Save.
  1. //Send mail to all the employees in the organization
  2. for each employee in Employee[ID != null]
  3. {
  4.   sendmail
  5.   [
  6.     from :zoho.adminuserid
  7.     to :employee.Official_Email
  8.     subject :"Season's greetings!"
  9.     message: "<div><img src=\" https://image.shutterstock.com/image-vector/seasons-greetings-brush-calligraphy-banner-260nw-1201986319.jpg\"> <br></div><div> Hi " + employee.Name) + ", <br></div><div> Here is wishing you the best this holiday! Happy " + input.Occasion + " from all of us!<br></div>"
  10.   ]
  11. }

The above code sends emails on the dates entered in the All Holidays List report.

See how it works

Points to Note

  • An automated email to each employee on their birthday can also be implemented similarly. Create a schedule to run annually on the Date Of Birth field of the Employee form. Click Add New Action and select Notification > Send mail (since the email is to be sent to one employee at a time). Configure the email to be sent in Send mail and click Save:
  1. Schedule
  2. Sendmail