Gmail — Delete
Gmail — Delete
Section titled “Gmail — Delete”Type: gmail-delete · Package: Gmail v1.0.4 · Output: —
Deletes an email. By default it moves it to Trash (recoverable); with permanent it deletes it for good.
How it works
Section titled “How it works”It works on the session created with Gmail — Connect. Pass it in the session parameter, or place this activity inside the body of Gmail — Connect to inherit it automatically.
- By default the email goes to Trash, where Gmail keeps it for about 30 days before deleting it; until then it can be recovered. Its
idstill exists and you can find it within:trash. - With
permanent = trueit is deleted right away, skipping Trash. For this the connection needs Gmail’s full scope (https://mail.google.com/); with narrower scopes, Gmail rejects it.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | Message ID. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanGmailSession | — | Gmail — Connect session (inherited inside body). |
permanent | bool | false | If true, deletes permanently (cannot be undone); if false, moves to Trash. |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'id' is required. | id is empty or the expression returned null. |
Requested entity was not found. | No email with that ID exists (for example, it was already deleted permanently). In batches that get retried, wrap the activity in a Try/Catch. |
Request had insufficient authentication scopes. | You used permanent = true and the connection lacks the https://mail.google.com/ scope. Add it to the connection or use Trash. |
Example
Section titled “Example”Gmail — Connect credential = credential("gmail-support") └─ body: Gmail — Get emails query = "older_than:1y category:promotions" maxResults = 100 → output: oldEmails For each email in oldEmails └─ Gmail — Delete id = email["id"]Related activities
Section titled “Related activities”- Gmail — Get emails — find the emails to delete.
- Gmail — Archive — take it out of the inbox without deleting.
- Gmail — Apply label — label instead of deleting.
- All Gmail activities