Skip to main content

List Folders

Lists the folders in a mail client.

Input

  • Client Id - The id of the mail client. The ID is created by the Connect node.

Output

  • Folders - An array of folder names.

Options

  • Credentials - The credentials of the mail client. Required if there is no Client Id.

How It Works

The List Folders node retrieves all available mailbox folders using IMAP LIST command. Here's the process:

  1. Authentication - Uses Client ID or direct credentials
  2. IMAP LIST Command - Executes LIST command to retrieve all folders
  3. Folder Parsing - Parses folder names from server response
  4. Return Results - Returns array of folder names

Requirements

  • Client ID from Connect node OR Credentials from vault with IMAP access

Error Handling

Error CodeDescriptionResolution
Core.Mail.Folders.ErrOnCreateConfig parse errorCheck node configuration
Core.Mail.Folders.ErrCredentialsInvalid credentialsVerify vault credentials
Core.Mail.Folders.ErrClientIdClient ID not foundEnsure Connect node executed
Core.Mail.Folders.ErrListCannot list foldersCheck IMAP connection and permissions
Core.Mail.ErrConnConnection missingEnsure Connect executed

Usage Examples

Example 1: List All Folders

{
"client_id": "{{client_id}}"
}
// Output: ["INBOX", "Sent", "Drafts", "Trash", "Archive", "Work/Projects", "Personal"]

Example 2: Check if Folder Exists

var folders = {{folders}};  // Output from List Folders
var targetFolder = "Archive";

if (folders.includes(targetFolder)) {
console.log("Archive folder exists");
} else {
console.log("Need to create Archive folder");
// Use Create Folder node
}

Example 3: Display Folder Structure

var folders = {{folders}};

console.log("Available folders:");
for (var folder of folders) {
console.log("- " + folder);
}
// Shows hierarchical structure with "/" separators

Usage Notes

  • Hierarchical Folders: Subfolders shown with "/" separator (e.g., "Archive/2024")
  • Standard Folders: INBOX, Sent, Drafts, Trash, Junk are common
  • Case Sensitivity: Folder names are case-sensitive
  • Server Differences: Folder structure varies by email provider
  • Special Folders: Some providers use special attributes for system folders

Tips

  • Validate Before Operations: Always list folders before moving/creating to avoid errors
  • Cache Results: Store folder list in variable to avoid repeated queries
  • Folder Organization: Plan folder structure before automating email organization
  • Check Provider Limits: Some providers limit folder depth or total folders