MOVE emails
This function moves messages to another folder. MOVE is part of the base IMAP4rev2 protocol (RFC 9051 §6.4.8); on IMAP4rev1 servers it requires the MOVE capability (RFC 6851) — check imap.capabilities if you're not sure your provider supports it.
Usage
await imap.move("INBOX/archive", "1:5") // move by sequence numbers
await imap.move("INBOX/archive", "42", true) // move a single UID
| Argument | Type | Description |
|---|---|---|
target | string | Destination folder. |
range | string | Sequence number range (or UID range with useUid), e.g. "1:5" or "42". |
useUid | boolean | Uses UID MOVE when true. |
Response
Like copy(), the function returns a CopyUidInfo ({ uidValidity, sourceUIDs, destUIDs }) when the server reports the moved UIDs via COPYUID, and null otherwise.
info
MOVE is a combined COPY + EXPUNGE — the messages are copied to the target folder and removed (with \Deleted) from the selected one. If your provider lacks MOVE, use copy() followed by storeFlags(..., ["Deleted"], "add") and expunge().