Skip to main content

COPY emails

This function copies messages to another folder.

Usage

await imap.copy("INBOX/archive", "1:5")              // copy by sequence numbers
await imap.copy("INBOX/archive", "42", true) // copy a single UID
ArgumentTypeDescription
targetstringDestination folder.
rangestringSequence number range (or UID range with useUid), e.g. "1:5" or "42".
useUidbooleanUses UID COPY when true.

Response

When the server reports the copied UIDs (the COPYUID response code, e.g. [COPYUID 432432 42:69 1202:1229]), the function returns:

type CopyUidInfo = {
uidValidity: number, // UIDVALIDITY of the destination mailbox
sourceUIDs: string, // UID set of the source messages
destUIDs: string // UID set of the copies in the destination
}

Otherwise (server doesn't send COPYUID) it returns null.

Throws an ImapError if the target folder doesn't exist or the range is invalid.