run_rule
Execute a saved email management rule in iCloud Mail to organize or process messages. Use dryRun mode to preview changes before applying them.
Instructions
Run a specific saved rule by name. Use dryRun: true to preview what would be affected without making changes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Rule name to run | |
| dryRun | No | If true, preview what would be affected without making changes |
Implementation Reference
- lib/imap.js:1919-1930 (handler)The 'runRule' function retrieves a rule by name, executes its associated action (using 'executeRule'), and updates the rule's metadata (lastRun, runCount) in the storage if dryRun is false.
export async function runRule(name, dryRun = false) { const data = readRules(); const rule = data.rules.find(r => r.name === name); if (!rule) throw new Error(`Rule '${name}' not found.`); const result = await executeRule(rule, dryRun); if (!dryRun) { rule.lastRun = new Date().toISOString(); rule.runCount = (rule.runCount || 0) + 1; writeRules(data); } return { rule: name, action: rule.action.type, ...result }; }