IMAP Delete
IMAP Delete
Section titled “IMAP Delete”Type: imap-delete · Package: SMTP / IMAP Email Activities v1.0.5
Deletes an email from the IMAP server. By default it moves it to the trash (recoverable); with permanent = true it is removed immediately.
How it works
Section titled “How it works”Given the mailId (from IMAP Read), it deletes the email from folder:
permanent = false(default): moves it to the folder the server declares as trash. If the server declares no trash folder, the email is deleted permanently and the log warnsEmail permanently deleted because the server has no Trash folder.permanent = true: flags it as deleted and compacts the folder (expunge) right away. Note that the expunge also removes other emails in that folder that were already flagged as deleted.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
host | string | — | IMAP server. |
username | string | — | Username. |
password | credential | — | Password or App Password. Use credential("name")["password"]. |
mailId | string | — | Email UID (from email.Id). Must be numeric. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
port | int | 993 | IMAP port. |
folder | string | "INBOX" | Folder that holds the email. |
permanent | bool | false | true = immediate, permanent deletion; false = to the trash. |
security | string | "ssl" | Encryption: auto, none, ssl or starttls. |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Invalid 'mailId'. It must be the numeric UID returned by imap-read. | mailId is not a number. Pass email.Id from IMAP Read. |
'mailId' is required. | The parameter is missing or the expression returned null. |
| Authentication, folder or connection error | Same as in IMAP Read. |
Example
Section titled “Example”Discard advertising emails, to the trash:
For Each items = emails itemVariable = email └─ activities: If condition = email.Subject.ToLower().Contains("advertising") └─ then: IMAP Delete host = "imap.gmail.com" username = credential("mail-bot")["user"] password = credential("mail-bot")["password"] mailId = email.IdRelated activities
Section titled “Related activities”- IMAP Move — archive to another folder instead of deleting.
- IMAP Mark Read — mark as read.