Get folders from Zoho Mail
Table of Contents
Note:
- This task is applicable to all Zoho services, except Zoho Creator.
- Each time the zoho.mail.getFolders 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.getFolders 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.getFolders task fetches the list of all the folders from Zoho Mail. This task is based on a Zoho Mail API.
Syntax
<response>=zoho.mail.getFolders(<connection>);
where:
| Params | Data type | Description |
| <response> | KEY-VALUE | The details including the type, name, ID, and ID of the parent folder of all the folders that will be fetched from Zoho Mail. |
<connection>
| TEXT | is the link name of the Zoho Mail connection Note:
|
Example
The following script retrieves all the folders from Zoho Mail:
response = zoho.mail.getFolders("mail_oauth_connection");
where:
response
The KEY-VALUE response that represents the details of all the folders fetched from Zoho Mail.
"mail_oauth_connection"
The TEXT that represents the link name of the Zoho Mail connection.
Response Format
Success Response
The success response returned will be in the the following format:
{
"ID":"6012326000000008019",
"TYPE":"Inbox",
"NAME":"Inbox"
"CHILDREN": [
{
"ID": "094480000000011003",
"TYPE": "Inbox",
"NAME": "folder1"
}
]
},
{
"PID":"6729326000000008013",
"ID":"6729326000000008015",
"TYPE":"Drafts",
"NAME":"Drafts"
},
{
"PID":"6729326000000008015",
"ID":"6729326000000008017",
"TYPE":"Templates",
"NAME":"Templates"
},
{
"PID":"6729326000000008017",
"ID":"6729326000000008019",
"TYPE":"Sent",
"NAME":"Sent"
},
{
"PID":"6729326000000008019",
"ID":"6729326000000008021",
"TYPE":"Spam",
"NAME":"Spam"
},
{
"PID":"6729326000000008023",
"ID":"6729326000000008025",
"TYPE":"Outbox",
"NAME":"Outbox"
},
{
"PID":"6729326000000548069",
"ID":"6729326000000548027",
"TYPE":"Inbox",
"NAME":"ZMGroup"
},
{
"PID":"6729326000000548027",
"ID":"6729326000000548015",
"TYPE":"Inbox",
"NAME":"ZMNewsLetter"
},
{
"PID":"6729326000000548015",
"ID":"6729326000000548003",
"TYPE":"Inbox",
"NAME":"ZMNotification"
}
"ID":"6012326000000008019",
"TYPE":"Inbox",
"NAME":"Inbox"
"CHILDREN": [
{
"ID": "094480000000011003",
"TYPE": "Inbox",
"NAME": "folder1"
}
]
},
{
"PID":"6729326000000008013",
"ID":"6729326000000008015",
"TYPE":"Drafts",
"NAME":"Drafts"
},
{
"PID":"6729326000000008015",
"ID":"6729326000000008017",
"TYPE":"Templates",
"NAME":"Templates"
},
{
"PID":"6729326000000008017",
"ID":"6729326000000008019",
"TYPE":"Sent",
"NAME":"Sent"
},
{
"PID":"6729326000000008019",
"ID":"6729326000000008021",
"TYPE":"Spam",
"NAME":"Spam"
},
{
"PID":"6729326000000008023",
"ID":"6729326000000008025",
"TYPE":"Outbox",
"NAME":"Outbox"
},
{
"PID":"6729326000000548069",
"ID":"6729326000000548027",
"TYPE":"Inbox",
"NAME":"ZMGroup"
},
{
"PID":"6729326000000548027",
"ID":"6729326000000548015",
"TYPE":"Inbox",
"NAME":"ZMNewsLetter"
},
{
"PID":"6729326000000548015",
"ID":"6729326000000548003",
"TYPE":"Inbox",
"NAME":"ZMNotification"
}
To fetch the IDs of the folders from the success response obtained, execute the following snippet:
for each var in <response_variable> { info var.get("ID"); }
To fetch the IDs of all the subfolders from the success response obtained, execute the following snippet:
for each folder in <response_variable> { //Fetch the list of subfolders of the folder in the current iteration subfolders_list = folder.get("CHILDREN"); // Check if the subfolders list is not empty if(subfolders_list!= null) { //Iterate through the list of subfolders and fetch their IDs for each child_folder in subfolders_list { info child_folder.get("ID") ; } } }
To fetch the subfolders IDs of the specified folder from the success response obtained, execute the following snippet:
for each folder in <response_variable> { //Fetch the ID of the current folder in the iteration folder_id = folder.get("ID") ; //Check if the current ID is the required ID if(folder_id == <required_folder_id>) { //Fetch the list of subfolders of the current folder in the iteration subfolders_list = folder.get("CHILDREN"); //Iterate through the list of subfolders and fetch their IDs for each child_folder in subfolders_list { info child_folder.get("ID") ; } } }