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:
- Authentication - Uses Client ID or direct credentials
- IMAP LIST Command - Executes LIST command to retrieve all folders
- Folder Parsing - Parses folder names from server response
- Return Results - Returns array of folder names
Requirements
- Client ID from Connect node OR Credentials from vault with IMAP access
Error Handling
| Error Code | Description | Resolution |
|---|---|---|
| Core.Mail.Folders.ErrOnCreate | Config parse error | Check node configuration |
| Core.Mail.Folders.ErrCredentials | Invalid credentials | Verify vault credentials |
| Core.Mail.Folders.ErrClientId | Client ID not found | Ensure Connect node executed |
| Core.Mail.Folders.ErrList | Cannot list folders | Check IMAP connection and permissions |
| Core.Mail.ErrConn | Connection missing | Ensure 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
Related Nodes
- Create Folder - Create new folders
- Delete Folder - Remove folders
- Move Mail - Move emails between folders
- Get Mail - Retrieve emails from specific folder