bulk_delete_by_subject
Delete multiple emails at once by matching a subject pattern in iCloud Mail. Use this tool to remove unwanted messages and maintain inbox organization through bulk operations.
Instructions
Delete all emails matching a subject pattern
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subject | Yes | Subject keyword to match | |
| mailbox | No | Mailbox (default INBOX) |
Implementation Reference
- lib/imap.js:899-913 (handler)The 'bulk_delete_by_subject' function implements the deletion logic by searching for emails with a specific subject and deleting them in chunks.
export async function bulkDeleteBySubject(subject, mailbox = 'INBOX', creds = null) { const client = createRateLimitedClient(creds); await client.connect(); await client.mailboxOpen(mailbox); const uids = (await client.search({ subject }, { uid: true })) ?? []; if (uids.length === 0) { await client.logout(); return { deleted: 0 }; } let deleted = 0; for (let i = 0; i < uids.length; i += CHUNK_SIZE) { const chunk = uids.slice(i, i + CHUNK_SIZE); await client.messageDelete(chunk, { uid: true }); deleted += chunk.length; } await client.logout(); return { deleted, subject }; }