Skip to content

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.

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 id still exists and you can find it with in:trash.
  • With permanent = true it 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.
ParameterTypeDefaultDescription
idstring—Message ID.
ParameterTypeDefaultDescription
sessionZoanGmailSession—Gmail — Connect session (inherited inside body).
permanentboolfalseIf true, deletes permanently (cannot be undone); if false, moves to Trash.

This activity does not return a value.

MessageCause 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.
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"]