Set Tag in Zoho Mail

Note:

  • This task is applicable to all Zoho services, except Zoho Creator.
  • Each time the zoho.mail.setTag integration task is executed, it triggers an API request in the back-end. This call is deducted from the external calls limit available for the service from which the task is executed, based on your pricing plan.
  • Only actual executions that receive a response (whether success or failure) are counted, not the number of times the task appears in the script. For example, if zoho.mail.setTag integration task is placed inside a for each task that iterates five times, the number of external calls consumed will be five, even though the task appears only once in the script. 

Overview

The zoho.mail.setTag task is used to set tags to the specified email in Zoho Mail.

Syntax

<response> = zoho.mail.setTag(<message_id>, <tag>, <connection>);

where:

ParamsData typeDescription
<response> KEY-VALUEThe response that represents the status of the executed task.
<message_id> NUMBERThe ID of the email to which the tag will be set.
<tag>NUMBER/ LIST/ TEXT

The ID or the name of the tag that will be set to the specified email.

Note:

  • The ID of the tag needs to be specified as NUMBER, name of the tag needs to be specified as TEXT.
  • Multiple tags can be set for the same email. For such a case, the tag IDs need to be specified as LIST of NUMBER values.
  • You can get the tag names and their IDs using Get Labels task. Click here to learn more about it.
<connection> TEXT

The link name of the connection.

Note:

  • In view of stopping new authtoken generation, a Zoho OAuth connection with appropriate scopes is mandatory for new integration tasks (created after the deadline specified in the post) to work as expected. Existing integration tasks will continue to work with or without the connections parameter unless the authtoken is manually deleted from accounts.
  • The scope required for this task as mentioned by Zoho Mail API is tags.
  • Refer to this post for the list of Zoho services that support the connections page.
  • Learn more about connections

Example 1: Set tag to an email using tag ID

The following example sets the tag with ID - 6729326000000548039 to the email with ID - 6729326000001836629 in Zoho Mail:

response  = zoho.mail.setTag(6729326000001836629, 6729326000000548039, "mail_oauth_connection");

where:

response
The KEY-VALUE response that represents the status of the executed task.
6729326000001836629
The NUMBER that represents the ID of the email to which the tag will be set.
6729326000000548039
The NUMBER that represents the ID of the tag.
"mail_oauth_connection"
The TEXT that represents the link name of Zoho Mail oauth connection.

Example 2: Set tag to an email using tag name

The following example sets the tag - blog to the email with ID - 6729326000001836629 in Zoho Mail:

response = zoho.mail.setTag(6729326000001836629, "blog", "mail_oauth_connection");

where:

"blog"
The TEXT that represents the ID of the tag.

Example 3: Set multiple tags to an email

The following example sets the tags specified in - tag_ids to the email with ID - 6729326000001836629 in Zoho Mail:

 // Create a list variable to hold the IDs of the tags that will be set to the specified email
 tag_ids = List();
 tag_ids.add(266980000000005034);
 tag_ids.add(266980000000005036);
 tag_ids.add(266980000000014001);
 
 // Execute the set tag task
 response = zoho.mail.setTag(6729326000001836629, tag_ids, "mail_oauth_connection");

where:

tag_ids
The LIST variable that holds the IDs of the tags.

Response

Success Response

  • The success response will be returned in the following format:

      {
       "message":"Action markLabels is successful",
       "status":"success"
       }

Failure Response

  • The failure response will be returned in the following format:

      {
       "message":"Error while processing the request! The label with label-id(s) [6729326000000008027] are not available",
       "status":"failure"
       }

Related Links