Delete Mail
Deletes a mail from a specified email account's mailbox.
Input
- Client Id - The id of the email account to access the mailbox. The ID is created by the Connect node.
- Mail Folder - The folder of the mailbox. The default value is INBOX.
- Message Id - The id of the email message to delete.
Options
- Credentials - The credentials to authenticate the email account. Required if there is no Client Id.
- Delete All - If true, deletes all mail in specified folder.
Notes
- If Message Id is provided, only the email with that id will be deleted.
- If Delete All is true, all messages in the specified folder will be deleted. The Message Id property will be ignored if Delete All is true.
How It Works
The Delete Mail node removes emails from a mailbox by marking them with the \Deleted flag. Here's the process:
- Authentication - Uses Client ID or direct credentials
- Folder Selection - Selects the specified mailbox folder
- Delete Mode Check - Determines if deleting single message or all messages
- Flag Setting - Marks email(s) with \Deleted flag
- Server Processing - Mail server processes deletion (may require EXPUNGE command)
Requirements
- Client ID from Connect node OR Credentials from vault
- Mail Folder - Valid folder name
- Message ID - Required if Delete All is false (UID of email)
Error Handling
| Error Code | Description | Resolution |
|---|---|---|
| Core.Mail.Delete.ErrOnCreate | Config parse error | Check node configuration |
| Core.Mail.Delete.ErrCredentials | Invalid credentials | Verify vault credentials |
| Core.Mail.Delete.ErrFolder | Folder name is empty | Provide folder name |
| Core.Mail.Delete.ErrTop | Invalid Message ID | Provide valid UID (over 0) |
| Core.Mail.Delete.ErrClientId | Client ID not found | Ensure Connect node executed |
| Core.Mail.Delete.ErrSelect | Cannot select folder | Verify folder exists |
| Core.Mail.Delete.ErrStore | Cannot mark email as deleted | Check write permissions |
| Core.Mail.ErrConn | Connection missing | Ensure Connect executed |
Usage Examples
Example 1: Delete Single Email by UID
{
"client_id": "{{client_id}}",
"mail_folder": "INBOX",
"message_id": 12345,
"delete_all": false
}
// Deletes email with UID 12345
Example 2: Delete All Emails in Folder
{
"client_id": "{{client_id}}",
"mail_folder": "Trash",
"delete_all": true
}
// Deletes all emails in Trash folder (permanent cleanup)
Example 3: Delete Search Results
// First, search for emails
var emails = {{search_results}};
// Delete each matching email
for (var email of emails) {
// Use Delete Mail node with email.uid
}
Usage Notes
- Deletion Behavior: Marks emails with \Deleted flag (soft delete)
- Permanent Deletion: Some servers auto-expunge, others require separate EXPUNGE command
- Delete All Caution: Delete All permanently removes all emails in folder
- Message ID Format: Use UID from Get Mail or Search Mail nodes
- Empty Folder: Deleting from empty folder completes without error
Tips
- Backup Important Emails: Move to archive before deleting
- Test First: Use Move Mail to test before deleting
- Batch Operations: Delete in batches for large cleanup tasks
- Verify UIDs: Confirm UID matches intended email before deletion
Related Nodes
- Move Mail - Move instead of delete
- Search Mail - Find emails to delete
- Get Mail - Get UIDs for deletion