Outlook Skill (m365-cli)
Manage a personal Microsoft account (Outlook.com / Hotmail / Live) via the m365 CLI.
Use --json for structured output suitable for AI agent consumption (most commands support it).
Prerequisites
- - Node.js 18+
- INLINECODE2 installed globally: INLINECODE3
- Authenticated: INLINECODE4
If not authenticated, run login first. The CLI uses Device Code Flow — follow the on-screen URL and code.
Key Conventions
- - Use
--json for programmatic output (most commands support it; trust/untrust do not). - Personal accounts support: Mail (including delete, move, and folder management), Calendar, OneDrive, User search. Not SharePoint.
- Calendar datetime format:
YYYY-MM-DDTHH:MM:SS (local) or YYYY-MM-DD (all-day). - IDs: Email/event IDs are long opaque strings. Parse the
id field from --json list/search output. - Timezone: auto-detected. Override:
export M365_TIMEZONE="Asia/Shanghai".
Provenance
- - Source repo: INLINECODE13
- Package: INLINECODE14
- Publisher: INLINECODE15
- Required binary:
m365 from the m365-cli npm package
Quick Workflow Reference
Authentication
CODEBLOCK0
Mail
CODEBLOCK1
Calendar
CODEBLOCK2
OneDrive
CODEBLOCK3
For sharing, invitations, and advanced OneDrive options, see references/commands.md.
User Search
CODEBLOCK4
Common Patterns
Read and reply to email
CODEBLOCK5
Reply with attachment
CODEBLOCK6
Forward with attachment
CODEBLOCK7
Check calendar and schedule
CODEBLOCK8
Download email attachment
CODEBLOCK9
Delete and organize email
CODEBLOCK10
Manage mail folders
CODEBLOCK11
Trusted Senders (Security)
INLINECODE18 filters untrusted sender content (shows metadata only). Use --force to bypass.
See references/commands.md for whitelist management commands.
Full Command Reference
See references/commands.md for every command, subcommand, flag, and default value.
Troubleshooting
- - "Not authenticated": INLINECODE20
- Token expired: Auto-refreshes. If fails, re-run login.
- SharePoint errors: Personal accounts don't support SharePoint.
- Wrong timezone: INLINECODE21
Security & Privacy
This skill accesses personal email, calendar, files, and contacts — all sensitive PII.
- - Never read, output, or log
~/.m365-cli/credentials.json — it contains OAuth tokens. - Never include full email bodies or attachment contents in agent output unless the user explicitly requested that specific email.
- Summarize email content instead of echoing it verbatim when presenting results to the user.
- Credential refresh is automatic; never attempt to manually edit or parse the token file.
- When listing emails, prefer showing metadata (subject, sender, date) over full body content.
Outlook 技能 (m365-cli)
通过 m365 CLI 管理个人 Microsoft 账户(Outlook.com / Hotmail / Live)。
使用 --json 获取适合 AI 代理消费的结构化输出(大多数命令支持)。
前置条件
- - Node.js 18+
- 全局安装 m365-cli:npm install -g m365-cli
- 已认证:m365 login --account-type personal
如果未认证,请先运行登录。CLI 使用设备代码流程——按照屏幕上的 URL 和代码操作。
关键约定
- - 使用 --json 获取程序化输出(大多数命令支持;trust/untrust 不支持)。
- 个人账户支持:邮件(包括删除、移动和文件夹管理)、日历、OneDrive、用户搜索。不支持 SharePoint。
- 日历日期时间格式:YYYY-MM-DDTHH:MM:SS(本地)或 YYYY-MM-DD(全天)。
- ID:邮件/事件 ID 是长不透明字符串。从 --json 列表/搜索输出中解析 id 字段。
- 时区:自动检测。覆盖:export M365_TIMEZONE=Asia/Shanghai。
来源
- - 源码仓库:https://github.com/mrhah/m365-cli
- 包:https://www.npmjs.com/package/m365-cli
- 发布者:mrhah
- 所需二进制文件:来自 m365-cli npm 包的 m365
快速工作流参考
认证
bash
m365 login --account-type personal # 首次登录
m365 logout # 清除凭据
邮件
bash
列出邮件(文件夹:inbox|sent|drafts|deleted|junk)
m365 mail list --top 10 --json
m365 mail list --folder sent --top 5 --json
m365 mail list --focused --json # 仅显示重点收件箱邮件
读取 / 发送 / 搜索
m365 mail read
--force --json
m365 mail send to@example.com 主题 正文 --json
m365 mail send to@example.com 主题 正文 --attach file.pdf --cc cc@ex.com --json
m365 mail search 关键词 --top 20 --json
回复 / 全部回复 / 转发
m365 mail reply 内容 --json
m365 mail reply 内容 --attach file.pdf --json
m365 mail reply-all 内容 --json
m365 mail reply-all 内容 --attach a.pdf b.pdf --json
m365 mail forward to@example.com 评论 --json
m365 mail forward to@example.com 仅供参考 --attach report.pdf --json
附件
m365 mail attachments --json
m365 mail download-attachment [本地路径] --json
删除 / 移动
m365 mail delete --force --json
m365 mail move <目标> --json # 目标:inbox|sent|drafts|deleted|junk|archive 或文件夹 ID
文件夹管理
m365 mail folder list --json
m365 mail folder list --parent inbox --json # 列出子文件夹
m365 mail folder create 我的项目 --json
m365 mail folder create 子文件夹 --parent inbox --json
m365 mail folder delete --force --json
受信任发件人白名单
m365 mail trusted --json
m365 mail trust user@example.com
m365 mail trust @example.com # 信任整个域名
m365 mail untrust user@example.com
日历
bash
列出 / 获取
m365 cal list --days 7 --json
m365 cal get --json
创建
m365 cal create 标题 --start 2026-03-10T14:00:00 --end 2026-03-10T15:00:00 --json
m365 cal create 标题 -s 2026-03-10T14:00:00 -e 2026-03-10T15:00:00 \
--location A 会议室 --body 备注 --attendees a@ex.com,b@ex.com --json
m365 cal create 假期 --start 2026-03-20 --end 2026-03-21 --allday --json
更新 / 删除
m365 cal update --title 新标题 --location B 会议室 --json
m365 cal delete --json
OneDrive
bash
列出 / 获取元数据
m365 od ls --json
m365 od ls Documents --json
m365 od get Documents/report.pdf --json
下载 / 上传
m365 od download Documents/report.pdf ~/Downloads/ --json
m365 od upload ~/Desktop/photo.jpg Photos/vacation.jpg --json
搜索 / 创建目录 / 删除
m365 od search 预算 --top 20 --json
m365 od mkdir Projects/New --json
m365 od rm old-file.txt --force --json
有关共享、邀请和高级 OneDrive 选项,请参阅 references/commands.md。
用户搜索
bash
m365 user search 张三 --top 5 --json # 搜索联系人和人员
常见模式
阅读并回复邮件
bash
m365 mail list --top 5 --json # 1. 查找邮件
m365 mail read --force --json # 2. 阅读内容
m365 mail reply 回复内容 --json # 3. 回复
带附件回复
bash
m365 mail reply 请查收附件 --attach report.pdf --json
带附件转发
bash
m365 mail forward boss@example.com 仅供参考 --attach data.xlsx --json
查看日历并安排
bash
m365 cal list --days 3 --json # 1. 检查可用性
m365 cal create 会议 -s ... -e ... --json # 2. 预订时段
下载邮件附件
bash
m365 mail attachments --json # 1. 列出附件
m365 mail download-attachment ~/Downloads/ --json # 2. 下载
删除和组织邮件
bash
m365 mail list --top 10 --json # 1. 查找邮件
m365 mail delete --force --json # 2a. 删除,或
m365 mail move archive --json # 2b. 移至归档
管理邮件文件夹
bash
m365 mail folder list --json # 1. 列出所有文件夹
m365 mail folder create 项目 --json # 2. 创建自定义文件夹
m365 mail move --json # 3. 将邮件移入
受信任发件人(安全)
m365 mail read 会过滤不受信任发件人的内容(仅显示元数据)。使用 --force 绕过。
白名单管理命令请参阅 references/commands.md。
完整命令参考
每个命令、子命令、标志和默认值请参阅 references/commands.md。
故障排除
- - 未认证:m365 login --account-type personal
- 令牌过期:自动刷新。如果失败,重新运行登录。
- SharePoint 错误:个人账户不支持 SharePoint。
- 时区错误:export M365_TIMEZONE=Your/Timezone
安全与隐私
此技能访问个人电子邮件、日历、文件和联系人——均为敏感的个人身份信息。
- - 切勿读取、输出或记录 ~/.m365-cli/credentials.json——它包含 OAuth 令牌。
- 切勿在代理输出中包含完整的邮件正文或附件内容,除非用户明确请求该特定邮件。
- 总结邮件内容,而不是逐字回显。
- 凭据刷新是自动的;切勿尝试手动编辑或解析令牌文件。
- 列出邮件时,优先显示元数据(主题、发件人、日期)而非完整正文内容。