---
title: "delete messages · RUAL Documentation"
description: "Deletes messages by UID: flags them \\Deleted and, by default, expunges them from the mailbox. Prefer imap move to the Trash folder when the account has…"
canonical: https://docs.rual.nl/block-types/imap/imapconnection_delete
language: en
---

[Cluster](https://docs.rual.nl/cluster)

[Blocks](https://docs.rual.nl/block-types)

[Interfaces](https://docs.rual.nl/interfaces)

[Blueprints](https://docs.rual.nl/blueprints)

[Blueprint Language](https://docs.rual.nl/engine)

[Tutorials](https://docs.rual.nl/tutorials)

[Home automation](https://docs.rual.nl/home-automation)

[Examples](https://docs.rual.nl/examples)

[Reference](https://docs.rual.nl/reference)

[Architecture](https://docs.rual.nl/architecture)

[Troubleshooting](https://docs.rual.nl/troubleshooting)

Other

# delete messages

This block is part of the [`imap`](https://docs.rual.nl/block-types/imap) group and was last modified in core [`v15.0.1`](https://docs.rual.nl/core-versions/150001).

Deletes messages by UID: flags them `\Deleted` and, by default, expunges them from the mailbox. Prefer `imap move` to the Trash folder when the account has one.

- flow `flow`

- connection required `imapconnection`

- mailbox `value` Mailbox the uids belong to. Defaults to `INBOX`.

Default `INBOX`

- uids `array` UIDs to delete.

- uid `number` A single UID, added to `uids`.

- expunge `condition` Remove the messages permanently (default). Off only flags them.

Default `true`

- allow mailbox-wide expunge `condition` On a server without UIDPLUS the only expunge is the whole mailbox's : every message any client flagged `\Deleted` goes with it. Off (default) refuses the expunge there; on accepts that.

Default `false`

- flow `flow`

- connection `imapconnection`

- success `condition`

- error `value`

- count `number`

Flags the uids \\Deleted in mailbox (default INBOX) and, with expunge=true (default), removes them permanently. expunge=false only sets the flag, for a mail client to act on. On a server without UIDPLUS the only expunge covers the whole mailbox (every message any client flagged \Deleted), so an expunging delete is REFUSED there before anything is flagged unless allow_mailbox_expunge=true : otherwise use expunge=false, or move to Trash. This is permanent : to keep a copy, imap move to Trash instead. Suppressed in a simulation.

| `remove email` |
| --- |
| `expunge` |
| `imap delete` |

A typical wiring for [delete messages](https://docs.rual.nl/block-types/imap/imapconnection_delete): a [function trigger](https://docs.rual.nl/block-types/globals/trigger_custom_function) starts the flow; [move messages](https://docs.rual.nl/block-types/imap/imapconnection_move) feeds the `connection` pin; the `flow` out pin feeds [debug](https://docs.rual.nl/block-types/state%2520ui/state_debug).

[![Studio canvas example for the delete messages block: typical wiring for delete messages.](https://docs.rual.nl/canvas-examples/imapconnection_delete.png)](https://docs.rual.nl/canvas-examples/imapconnection_delete.png?v=3)

## Version history

Introduced in [`v15.0.1`](https://docs.rual.nl/core-versions/150001).

- [Back to `imap`](https://docs.rual.nl/block-types/imap): Return to the main group to view all sub-groups

- [Back to `imap`](https://docs.rual.nl/block-types/imap?group=imap): Return to the group to view all blocks within this group

Was this page helpful? [Tell us what to improve](https://docs.rual.nl/support) · RUAL Docs is an integral component of the [RUAL ecosystem](https://rual.nl)
