Skip to main content

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:

  1. Authentication - Uses Client ID or direct credentials
  2. Folder Selection - Selects the specified mailbox folder
  3. Delete Mode Check - Determines if deleting single message or all messages
  4. Flag Setting - Marks email(s) with \Deleted flag
  5. 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 CodeDescriptionResolution
Core.Mail.Delete.ErrOnCreateConfig parse errorCheck node configuration
Core.Mail.Delete.ErrCredentialsInvalid credentialsVerify vault credentials
Core.Mail.Delete.ErrFolderFolder name is emptyProvide folder name
Core.Mail.Delete.ErrTopInvalid Message IDProvide valid UID (over 0)
Core.Mail.Delete.ErrClientIdClient ID not foundEnsure Connect node executed
Core.Mail.Delete.ErrSelectCannot select folderVerify folder exists
Core.Mail.Delete.ErrStoreCannot mark email as deletedCheck write permissions
Core.Mail.ErrConnConnection missingEnsure 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