mark_older_than_read
Mark unread emails older than a specified number of days as read to clean up your inbox through bulk triage.
Instructions
Mark all unread emails older than N days as read. Useful for bulk triage of a cluttered inbox.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | Yes | Mark emails older than this many days as read | |
| mailbox | No | Mailbox (default INBOX) |
Implementation Reference
- lib/imap.js:867-879 (handler)The function `markOlderThanRead` marks emails older than a specified number of days as read. It connects to the IMAP server, searches for unread messages before the calculated date, and adds the `\Seen` flag to them.
export async function markOlderThanRead(days, mailbox = 'INBOX', creds = null) { const client = createRateLimitedClient(creds); await client.connect(); await client.mailboxOpen(mailbox); const date = new Date(); date.setDate(date.getDate() - days); const raw = await client.search({ before: date, seen: false }, { uid: true }); const uids = Array.isArray(raw) ? raw : []; if (uids.length === 0) { await client.logout(); return { marked: 0, olderThan: date.toISOString() }; } await client.messageFlagsAdd(uids, ['\\Seen'], { uid: true }); await client.logout(); return { marked: uids.length, olderThan: date.toISOString() }; }