Skip to content
Back to skills

Automating Mail

ASecurity

Automates Apple Mail via JXA with AppleScript dictionary discovery. Use when asked to "automate email", "send mail via script", "JXA Mail automation", or "filter email messages". Covers accounts, mailboxes, batch message filtering, composition, attachments, and UI fallback.

  • 40 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 7, 2026
data-aijavascriptpythonrustgojavashellbashapisecurityperformance

Works with

  • api

Security analysis

A100/100

Pro scans all 17 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add SpillwaveSolutions/automating-mac-apps-plugin --skill automating-mail --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Automating Mail?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Automating Mail
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/spillwavesolutions-automating-mail/badge)](https://www.skillsdirectory.com/skills/spillwavesolutions-automating-mail)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: automating-mail
description: Automates Apple Mail via JXA with AppleScript dictionary discovery. Use when asked to "automate email", "send mail via script", "JXA Mail automation", or "filter email messages". Covers accounts, mailboxes, batch message filtering, composition, attachments, and UI fallback.
allowed-tools:
  - Bash
  - Read
  - Write
---

# Automating Apple Mail (JXA-first, AppleScript discovery)

## Contents
- [Relationship to macOS automation skill](#relationship-to-the-macos-automation-skill)
- [Core Framing](#core-framing)
- [Workflow](#workflow-default)
- [Quick Start Examples](#quick-start-examples)
- [Validation Checklist](#validation-checklist)
- [When Not to Use](#when-not-to-use)
- [What to load](#what-to-load)

## Relationship to the macOS automation skill
- Use `automating-mac-apps` for permissions, shell, and UI scripting guidance.
- **PyXA Installation:** See `automating-mac-apps` skill (PyXA Installation section).

## Core Framing
- Mail dictionary is AppleScript-first; discover in Script Editor.
- Objects are specifiers: read via method calls (`message.subject()`), modify via assignments (`message.readStatus = true`).
- ObjC bridge available for advanced filesystem operations.

## Workflow (default)
1) [ ] Ensure Mail configured and automation permissions enabled.
2) [ ] Discover terms in Script Editor (Mail dictionary).
3) [ ] Prototype minimal AppleScript command.
4) [ ] Port to JXA with defensive checks.
5) [ ] Use batch reads for performance.
6) [ ] Use UI scripting for signature and UI-only actions.

## Quick Start Examples

**Read inbox (JXA):**
```javascript
const Mail = Application('Mail');
const message = Mail.inbox.messages[0];
console.log(message.subject());
```

**Compose message (JXA):**
```javascript
const msg = Mail.OutgoingMessage({
  subject: "Status Update",
  content: "All systems go."
});
Mail.outgoingMessages.push(msg);
msg.visible = true;
```

**PyXA alternative:**
```python
import PyXA
mail = PyXA.Mail()
inbox = mail.inboxes()[0]
message = inbox.messages()[0]
print(f"Subject: {message.subject()}")
```

## Validation Checklist
- [ ] Automation permissions granted (System Settings > Privacy > Automation)
- [ ] Inbox access works: `Mail.inbox.messages.length`
- [ ] Message property reads return expected values
- [ ] Composition creates visible draft
- [ ] Batch operations complete without errors

## When Not to Use
- For cross-platform email automation (use IMAP/SMTP libraries)
- For bulk email sending (use transactional email services like SendGrid)
- When processing untrusted email content (security risk)
- For non-macOS platforms

## What to load
- Mail JXA basics: `automating-mail/references/mail-basics.md`
- Recipes (filter, move, compose): `automating-mail/references/mail-recipes.md`
- Advanced patterns (batch ops, HTML, signatures): `automating-mail/references/mail-advanced.md`
- Dictionary translation table: `automating-mail/references/mail-dictionary.md`
- Rule scripts: `automating-mail/references/mail-rules.md`
- HTML + signature workflow: `automating-mail/references/html-signature-workflow.md`
- Attachment extraction pipeline: `automating-mail/references/attachment-extraction.md`
- Mailbox archiver: `automating-mail/references/mailbox-archiver.md`
- HTML data merge: `automating-mail/references/html-data-merge.md`
- **PyXA API Reference** (complete class/method docs): `automating-mail/references/mail-pyxa-api-reference.md`

Files in this skill

  • SKILL.md3.4 KB
  • references/attachment-extraction.md583 B
  • references/html-data-merge.md544 B
  • references/html-signature-workflow.md577 B
  • references/mail-advanced.md3 KB
  • references/mail-basics.md1.3 KB
  • references/mail-dictionary.md632 B
  • references/mail-pyxa-api-reference.md23.1 KB
  • references/mail-recipes.md1.9 KB
  • references/mail-rules.md988 B
  • references/mailbox-archiver.md649 B
  • scripts/create_email.py1.1 KB
  • scripts/create_mail_rule.py2.2 KB
  • scripts/extract_emails_to_contacts.py2.4 KB
  • scripts/search_and_archive.py2.5 KB
  • scripts/set_up_mail_automation.py925 B
  • scripts/set_up_mail_automation.sh480 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.