Skip to content

Outlook 365 — Delete

Type: outlook365-delete  ·  Package: Outlook 365 v1.0.4  ·  Output: —

Deletes an email from the mailbox. Use it to clean up what doesn’t need to be kept: automatic notices, junk mail, duplicates.

It works on the session created with Outlook 365 — Connect. Pass it in the session parameter, or place this activity inside the body of Outlook 365 — Connect to inherit it automatically.

Identify the email with its id (from Get emails). The deletion is performed by Microsoft Graph and follows the mailbox’s retention policy: it is not an immediate irreversible deletion, and the Microsoft 365 administrator can recover the email while retention lasts. If you’d rather keep the email visible in Deleted Items for someone to review, use Move with destination = "deleteditems".

After deletion, its id no longer works with the other activities.

ParameterTypeDefaultDescription
idstring—Message ID.
ParameterTypeDefaultDescription
sessionZoanOutlookMailSession—Outlook 365 — Connect session (inherited inside body).

This activity does not return a value.

MessageCause and fix
'id' is required.id is empty or the expression returned null.
Graph error ErrorItemNotFoundNo email exists with that ID anymore (already deleted or moved). If you retry a batch, wrap the activity in a Try/Catch so an already-deleted email doesn’t stop the rest.
Outlook 365 — Connect credential = credential("m365-support")
└─ body:
Outlook 365 — Get emails folder = "junkemail" maxResults = 100 → output: junk
For each email in junk
└─ Outlook 365 — Delete id = email["id"]