Get folders from Zoho Mail
Table of Contents
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
"mail_oauth_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"
}
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") ; } } }