automating-mail

Automates Apple Mail via JXA and PyXA for reading, composing, filtering, and archiving messages.

3|1|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/wopal-cn/wopal-space-ontology --skill automating-mail-wopal-cn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: automating-mail
Source: https://github.com/wopal-cn/wopal-space-ontology/tree/main/skills/automating-mail
Command: npx skills add https://github.com/wopal-cn/wopal-space-ontology --skill automating-mail-wopal-cn

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires PyXA, and includes scripts (resource) and references (resource) components.

What problem does it solve? Manually managing Apple Mail—reading inboxes, composing messages, filtering emails, extracting attachments, and organizing mailboxes—is repetitive and time-consuming. This Skill provides scriptable control over Mail.app so these tasks can be automated on macOS. ## Core Features & Use Cases - JXA-first automation with AppleScript dictionary discovery: Read inboxes, batch-filter messages by flags or read status, and move messages between mailboxes using JavaScript for Automation. - PyXA Python alternative: Compose outgoing messages, add recipients and attachments, reply, forward, and send mail from Python scripts. - Ready-made scripts and references: Includes scripts for creating emails, searching and archiving messages, extracting addresses to Contacts, and triggering automation permission prompts, plus detailed references covering rules, HTML signatures, attachment extraction, and a full PyXA API reference. - Use Case: Archive all messages older than 30 days across every iCloud mailbox, or compose an HTML status report email with a signature and send it automatically. ## Quick Start Ask the AI to read the latest message subject from your Apple Mail inbox using JXA, then compose a reply draft with a given subject and body.

Frequently Asked Questions about automating-mail

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate Apple Mail with JXA?

Use Application("Mail") in JavaScript for Automation to access accounts, mailboxes, and messages. Read properties via method calls like message.subject() and modify state via assignments like message.readStatus = true. Discover available terms in Script Editor's Mail dictionary first.

How to compose and send an email with PyXA in Python?

Create a message with mail.outgoing_messages().push() passing subject, content, and recipients, then call msg.send() to send it. Set visible to True first if you want to review the draft in a compose window before sending.

JXA vs PyXA for Mail automation, which should I use?

JXA is the primary approach since the Mail dictionary is AppleScript-first and maps directly to JXA specifiers. PyXA offers a Pythonic alternative with the same capabilities, useful when integrating Mail automation into existing Python workflows.

Why does Mail automation fail with permission errors?

macOS requires explicit Automation permission for the calling application to control Mail. Run the provided setup script to trigger the permission prompt, then grant access under System Settings > Privacy & Security > Automation.

When should I not use Apple Mail scripting for email automation?

Avoid it for cross-platform email automation, where IMAP/SMTP libraries are better, and for bulk sending, where transactional services like SendGrid fit. It is macOS-only and should not process untrusted email content due to security risk.