apple-mail
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseApple Mail Skill
Apple Mail 技能
This skill provides commands to interact with Apple Mail on macOS via AppleScript.
本技能提供了通过AppleScript在macOS上与Apple Mail交互的命令。
Available Scripts
可用脚本
All scripts are in the directory (relative to this file). Execute them via bash from the plugin root.
../../scripts/所有脚本都位于相对于本文件的目录中。从插件根目录通过bash执行它们。
../../scripts/Account & Mailbox Management
账户与邮箱管理
| Script | Purpose | Arguments |
|---|---|---|
| List all email accounts | none |
| List mailboxes/folders | |
| Get unread email count | |
| 脚本 | 用途 | 参数 |
|---|---|---|
| 列出所有邮箱账户 | 无 |
| 列出邮箱/文件夹 | |
| 获取未读邮件数量 | |
Reading Emails
读取邮件
| Script | Purpose | Arguments |
|---|---|---|
| Get recent emails | |
| Get specific email by ID | |
| Search emails | |
| 脚本 | 用途 | 参数 |
|---|---|---|
| 获取近期邮件 | |
| 通过ID获取特定邮件 | |
| 搜索邮件 | |
Sending & Composing
发送与撰写
| Script | Purpose | Arguments |
|---|---|---|
| Send an email | |
| Create a draft email | |
| Create reply to email | |
| Send front-most draft | none |
| 脚本 | 用途 | 参数 |
|---|---|---|
| 发送邮件 | |
| 创建草稿邮件 | |
| 创建邮件回复草稿 | |
| 发送最前端的草稿 | 无 |
Email Management
邮件管理
| Script | Purpose | Arguments |
|---|---|---|
| Archive an email | |
| Delete an email | |
| Mark email as read | |
| Mark email as unread | |
| 脚本 | 用途 | 参数 |
|---|---|---|
| 归档邮件 | |
| 删除邮件 | |
| 标记邮件为已读 | |
| 标记邮件为未读 | |
Output Format
输出格式
Scripts use delimiters for structured output:
- separates fields within a record
<<>> - separates multiple records
||| - prefix indicates an error message
ERROR:
脚本使用分隔符实现结构化输出:
- 分隔一条记录内的各个字段
<<>> - 分隔多条记录
||| - 前缀表示错误信息
ERROR:
Email Record Format
邮件记录格式
id<<>>subject<<>>sender<<>>to<<>>cc<<>>bcc<<>>dateSent<<>>isRead<<>>content|||id<<>>subject<<>>sender<<>>to<<>>cc<<>>bcc<<>>dateSent<<>>isRead<<>>content|||Usage Examples
使用示例
List accounts
列出账户
bash
./scripts/list-accounts.shbash
./scripts/list-accounts.shGet recent emails from INBOX
获取收件箱中的近期邮件
bash
./scripts/get-emails.sh "" "INBOX" 10 false falsebash
./scripts/get-emails.sh "" "INBOX" 10 false falseGet recent unread emails with content
获取包含内容的近期未读邮件
bash
./scripts/get-emails.sh "" "INBOX" 10 true truebash
./scripts/get-emails.sh "" "INBOX" 10 true trueGet specific email by ID
通过ID获取特定邮件
bash
./scripts/get-email-by-id.sh 12345 "iCloud" "INBOX" truebash
./scripts/get-email-by-id.sh 12345 "iCloud" "INBOX" trueSearch emails
搜索邮件
bash
./scripts/search-emails.sh "meeting notes" "" "" 20bash
./scripts/search-emails.sh "meeting notes" "" "" 20Send an email
发送邮件
bash
./scripts/send-email.sh "recipient@example.com" "Subject" "Body text"bash
./scripts/send-email.sh "recipient@example.com" "Subject" "Body text"Send with CC and BCC
发送带抄送和密送的邮件
bash
./scripts/send-email.sh "to@example.com" "Subject" "Body" "cc@example.com" "bcc@example.com"bash
./scripts/send-email.sh "to@example.com" "Subject" "Body" "cc@example.com" "bcc@example.com"Create a draft
创建草稿
bash
./scripts/create-draft.sh "Draft Subject" "Draft body" "recipient@example.com"bash
./scripts/create-draft.sh "Draft Subject" "Draft body" "recipient@example.com"Reply to an email
回复邮件
bash
./scripts/create-reply-draft.sh 12345 "Thanks for your message!" false "iCloud" "INBOX"bash
./scripts/create-reply-draft.sh 12345 "Thanks for your message!" false "iCloud" "INBOX"Send the front-most draft
发送最前端的草稿
bash
./scripts/send-draft.shbash
./scripts/send-draft.shArchive an email
归档邮件
bash
./scripts/archive-email.sh 12345 "iCloud" "INBOX"bash
./scripts/archive-email.sh 12345 "iCloud" "INBOX"Mark as read/unread
标记为已读/未读
bash
./scripts/mark-read.sh 12345 "iCloud" "INBOX"
./scripts/mark-unread.sh 12345 "iCloud" "INBOX"bash
./scripts/mark-read.sh 12345 "iCloud" "INBOX"
./scripts/mark-unread.sh 12345 "iCloud" "INBOX"Parsing Output
输出解析
When receiving email records, parse them like this:
- Split by to get individual records
||| - Split each record by to get fields
<<>> - Fields are: id, subject, sender, to, cc, bcc, dateSent, isRead, content
Example parsing in bash:
bash
IFS='|||' read -ra emails <<< "$output"
for email in "${emails[@]}"; do
IFS='<<>>' read -ra fields <<< "$email"
id="${fields[0]}"
subject="${fields[1]}"
sender="${fields[2]}"
# ... etc
done接收邮件记录时,可按以下方式解析:
- 使用分割以获取单个记录
||| - 使用分割每条记录以获取各个字段
<<>> - 字段依次为:id、subject、sender、to、cc、bcc、dateSent、isRead、content
Bash中的解析示例:
bash
IFS='|||' read -ra emails <<< "$output"
for email in "${emails[@]}"; do
IFS='<<>>' read -ra fields <<< "$email"
id="${fields[0]}"
subject="${fields[1]}"
sender="${fields[2]}"
# ... 以此类推
doneNotes
注意事项
- Scripts require macOS with Apple Mail configured
- Apple Mail must have at least one account set up
- First run may trigger macOS permission prompts for automation
- Empty optional arguments should be passed as empty strings ""
- For scripts that need arrays (multiple recipients), pass comma-separated values
- 脚本需要配置好Apple Mail的macOS系统
- Apple Mail必须至少设置一个账户
- 首次运行可能会触发macOS的自动化权限提示
- 可选参数为空时应传入空字符串""
- 对于需要数组的脚本(如多个收件人),传入逗号分隔的值
Reference
参考资料
For advanced AppleScript patterns and customization, see .
./reference/applescript-patterns.md如需高级AppleScript模式和自定义内容,请查看。
./reference/applescript-patterns.md