Exchange Mail
Manage Microsoft Exchange/Outlook emails and calendar from terminal.
Script Location
INLINECODE0 - Main CLI script
Commands
CODEBLOCK0
Note:
- - Contact search requires access to Exchange contact folders. If no contacts are found, check folder permissions on the Exchange server.
- Tasks and Notes require the corresponding folders to exist in the Exchange account.
Email IDs
Each email gets stable 8-char hex ID (e.g., b7bc8d99). Use for all commands.
Output Format
CODEBLOCK1
Batch Flags
- -
--external - Only external emails (outside your domain) - INLINECODE3 - Only internal emails (your domain)
- INLINECODE4 - All emails
- INLINECODE5 - Look back N days (default: today only)
Environment Variables
Required in shell config:
CODEBLOCK2
Optional:
CODEBLOCK3
Note: The script will also load environment variables from a .env file in the script directory (skills/exchange-skills/scripts/.env) if it exists.
Workflow Examples
CODEBLOCK4
Exchange 邮件
从终端管理 Microsoft Exchange/Outlook 邮件和日历。
脚本位置
scripts/exchange_mail.py - 主 CLI 脚本
命令
bash
列出未读邮件(今日,收件人或抄送中包含你)
python3 scripts/exchange_mail.py list
列出选项
python3 scripts/exchange_mail.py list --days 3 # 最近3天
python3 scripts/exchange_mail.py list --all # 所有未读
python3 scripts/exchange_mail.py list --json # JSON 输出
阅读邮件
python3 scripts/exchange_mail.py read
回复
python3 scripts/exchange_mail.py reply 你的消息
标记为已读
python3 scripts/exchange_mail.py mark-read
python3 scripts/exchange_mail.py mark-read --external
python3 scripts/exchange_mail.py mark-read --internal
python3 scripts/exchange_mail.py mark-read --all
归档
python3 scripts/exchange_mail.py archive
python3 scripts/exchange_mail.py archive --external
python3 scripts/exchange_mail.py archive --internal --days 7
日历(新功能!)
python3 scripts/exchange_mail.py calendar # 未来7天
python3 scripts/exchange_mail.py calendar --today # 仅今日
python3 scripts/exchange_mail.py calendar --days 30 # 未来30天
python3 scripts/exchange_mail.py calendar --json # JSON 输出
联系人(新功能!)
python3 scripts/exchange_mail.py contacts 姓名 # 搜索联系人
python3 scripts/exchange_mail.py contacts 姓名 --limit 10 # 限制结果数
python3 scripts/exchange_mail.py contacts 姓名 --json # JSON 输出
任务(新功能!)
python3 scripts/exchange_mail.py tasks # 列出任务
python3 scripts/exchange_mail.py tasks --days 30 # 未来30天
python3 scripts/exchange_mail.py tasks --status pending # 按状态筛选
笔记(新功能!)
python3 scripts/exchange_mail.py notes # 列出笔记
python3 scripts/exchange_mail.py notes --limit 10 # 限制结果数
注意:
- - 联系人搜索需要访问 Exchange 联系人文件夹。如果未找到联系人,请检查 Exchange 服务器上的文件夹权限。
- 任务和笔记需要在 Exchange 账户中存在相应的文件夹。
邮件 ID
每封邮件会获得一个固定的 8 字符十六进制 ID(例如 b7bc8d99)。所有命令均使用此 ID。
输出格式
📧 今日有 9 封未读邮件:
━━━ 内部邮件(4 封)━━━
[b7bc8d99] [13:57] John Smith
回复:项目讨论
━━━ 外部邮件(5 封)━━━
[43e56cc9] [09:50] newsletter@company.com
每周更新
批量标志
- - --external - 仅外部邮件(你所在域之外)
- --internal - 仅内部邮件(你所在域)
- --all - 所有邮件
- --days N - 回溯 N 天(默认:仅今日)
环境变量
需在 shell 配置中设置:
bash
export EXCHANGE_SERVER=mail.company.com
export EXCHANGE_EMAIL=user@company.com
export EXCHANGE_USERNAME=username
export EXCHANGE_PASSWORD=password
可选:
bash
export EXCHANGE_DOMAIN=domain # 如果需要 Windows 域
export EXCHANGEDISABLESSL_VERIFY=1 # 仅当你需要禁用 SSL 验证时使用(不推荐)
注意:如果脚本目录(skills/exchange-skills/scripts/.env)中存在 .env 文件,脚本也会从中加载环境变量。
工作流程示例
bash
早晨:查看 → 阅读 → 回复 → 归档垃圾邮件
python3 scripts/exchange_mail.py list
python3 scripts/exchange_mail.py read abc123
python3 scripts/exchange_mail.py reply abc123 谢谢!
python3 scripts/exchange_mail.py archive --external
每周清理
python3 scripts/exchange_mail.py archive --external --days 7