Outlook 365 — Delete
Outlook 365 — Delete
Section titled “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.
How it works
Section titled “How it works”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.
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 | ZoanOutlookMailSession | — | Outlook 365 — Connect session (inherited inside body). |
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. |
Graph error ErrorItemNotFound | No 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. |
Example
Section titled “Example”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"]Related activities
Section titled “Related activities”- Outlook 365 — Move — archive instead of deleting.
- Outlook 365 — Get emails — find the emails to delete.
- Outlook 365 — Mark read/unread — mark as read.
- All Outlook 365 activities