Custom Function

Zoho Mail Filters now support Custom Functions via Deluge Scripting in Zoho creator. This allows you to customize the Filter Conditions and Actions using multiple parameters. This helps you to create and write Simple Deluge scripts, to create custom Actions and set them as Conditions or Actions in your Filters in Zoho Mail. Further, this enables you to setup Workflows which can be triggered by emails based on specific conditions and customizable actions.

Gallery Functions:

Gallery Functions are readymade scripts available to you to install and use directly. Certain gallery functions published there might need some little customizations to make them applicable to your exact scenario or use case. These pre-written functions also serve as a reference for retrieving the mail related parameters or actions related to mail, when you write your own custom Deluge scripts. 

Gallery functions

Steps to Add Custom Actions in Filters: 

  1. Login to Zoho Mail
  2. Click the Settings  icon.
  3. Go to Filters
  4. Click New Filter to add a new filter.
  5. Provide the basic conditions (Example: Sender/ Subject etc)
  6. In the actions, select 'Custom function (Creator)' from the drop-down. 
  7. Click Select Function to view the Deluge Script editor popup. 
  8. You can create your own functions or choose a gallery function here. 
    Custom functions​​
  9. Once you create your own set of functions, you can directly choose them in the Action area. 


You can also establish connections with any third-party application of your preference using DRE Connectors.

Zoho Mail in Deluge:

Zoho Mail provides certain actions in Deluge to retrieve metadata information of the current user/ the related email that can be retrieved via Deluge Script:

  • getFolders - Lists all Folders for the given account.
  • getLabels - Lists all labels for the given accounts.
  • getMessage - Retrieve details of an email.

Actions supported in Zoho Mail via Deluge Script: 

AND / OR Conditions in Filter: 

Currently, Zoho Mail filters do not directly support a combination of OR and AND usage between multiple conditions. In case you have such custom requirement, you can create and use Deluge scripts in Custom Actions to organize your Inbox or create a custom rule for such emails. 

Ex: You can create a filter with conditions like below:

If (sender = <> or sender=<>) and subject = subject1 then move email to the folder <folder x>. 

Custom Workflows:

Custom Action support in Zoho Mail helps you to integrate Zoho Mail with other Zoho applications or external applications and create workflows based on incoming and outgoing emails. 


If Subject = "Contact us" or To = "" then Add Sender as a lead in Zoho CRM. 

If Subject = "Invoice xxxx" then extract total amount and Add it to the database <abcde> in Zoho Reports. 

Content based Filters: 

The default email filter conditions support only the parameters available in the email metadata. Hence it is not possible to create filters with 'Content' based conditions. With Custom Actions in place, you can write your script to create Content based conditions and actions for incoming and outgoing emails to organize them better or create custom workflows. 

Sample Scripts:

Chain Actions in a single custom function

// To get the email data, use the 'mail_messageId' parameter
// sent from mail filter when calling the Dre function.

messageDetails = zoho.mail.getMessage(mail_messageId);
mailContent = messageDetails.get("CONTENT");
mailSubject = messageDetails.get("SUBJECT");
fromAddress = messageDetails.get("FROM");
moveToFolderPath = "/ToDoList";
myTask = 123456;
othersTask = 234567;

Get the Label Details for a given label name:

tagId= -1;
tagDetails = zoho.mail.getLabels();
        for each  tag in tagDetails
            if(tag.get("NAME") == "High Priority")
                tagId = tag.get("ID");


Convert SentDateTime parameter to Creator Date Time format

Time zone has to be changed in accordance with TimeZone in Input Parameter

messageDetails = zoho.mail.getMessage(mail_messageId);
mailDate = messageDetails.get("SENTTIME");
mailDateString = mailDate.toDate("E, dd MMM yyyy HH:mm:ss +0530");  //gives output in format 20-Apr-2017
mailDateTimeString = mailDate.toTime("E, dd MMM yyyy HH:mm:ss +0530");  //gives output in format 20-Apr-2017 13:23:06 

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

Write to us: