Microsoft Outlook/Live.com email and calendar client via Microsoft Graph API. List, search, read, send emails. View and create calendar events. Supports devi...
Command-line email and calendar client for Microsoft Outlook/Live/Hotmail using Microsoft Graph API.
Version: 2.0
Features:
Required Tools:
Bash: Execute Python CLI scriptRead: Read token and configuration filesWrite: Store OAuth tokens and settingsNetwork Access:
graph.microsoft.com)requests library for HTTP communicationsData Storage:
~/.config/outlook-cli/token.json (requires file permission 600)Python Dependencies:
requests library⚠️ 安全提示:
- 请 仅从官方 Microsoft Azure 门户 ( https://portal.azure.com) 创建应用并获取凭据
- 切勿使用 来自非官方渠道、第三方网站或他人分享的凭据
- Client ID 和 Tenant ID 可以公开,但 Client Secret 必须保密
- 定期审查和轮换凭据以提高安全性
- 仅授予必需的最小权限(遵循最小权限原则)
Create Azure AD App: https://portal.azure.com → App registrations
outlook-clihttp://localhost:8080/callbackAdd API permissions (Microsoft Graph, Delegated):
Mail.Read, Mail.ReadWrite, Mail.SendCalendars.Read, Calendars.ReadWriteUser.Read, offline_accessGet credentials from your app registration
Configure: bash
outlook configure
Authenticate: bash
# For local environment with browser
outlook auth
# For servers/headless environments (recommended)
outlook auth --device-code
Secure token file (Critical!): bash
# Set restrictive permissions
chmod 600 ~/.config/outlook-cli/token.json
# Verify (should show: -rw-------)
ls -l ~/.config/outlook-cli/token.json
⚠️ Important: Never commit this file to version control or share it with others!
CommandDescriptionoutlook list [n]List recent emailsoutlook search "query" [n]Search emailsoutlook read <id>Read email by IDoutlook send --to ...Send emailoutlook reply <id>Reply to emailoutlook statusCheck auth status
CommandDescriptionoutlook calendar list [--days N]List upcoming eventsoutlook calendar create ...Create calendar event
List emails:
bash
outlook list 20
返回格式示例:
text
│ 序号 │ 发件人 │ 主题 │ 日期 │ 状态 │
├──────┼────────────────────────────┼───────────────────────────────┼──────────────────┼────────┤
│ 1 │ user@example.com │ 项目进展汇报 │ 2026-03-19 10:30 │ 未读 │
│ 2 │ admin@company.com │ 周会通知 │ 2026-03-19 09:15 │ ✓ 已读 │
│ 3 │ noreply@service.com │ 账户安全提醒 │ 2026-03-18 18:20 │ 未读 │
Search:
bash
outlook search "from:linkedin.com"
outlook search "subject:invoice"
outlook search "hasattachment:yes"
Send:
bash
outlook send --to "user@example.com" --subject "Hello" --body "Message"
outlook send --to "a@x.com,b@x.com" --cc "boss@x.com" --subject "Update" --body-file ./msg.txt
Reply:
bash
outlook reply EMAIL_ID --body "Thanks!"
outlook reply EMAIL_ID --all --body "Thanks everyone!"
View events:
bash
# Next 7 days (default)
outlook calendar list
# Next 14 days
outlook calendar list --days 14
Create event:
bash
# Simple event
outlook calendar create \
--subject "Team Meeting" \
--date "2026-03-20" \
--time "14:00" \
--duration 60
# With attendees and location
outlook calendar create \
--subject "Project Review" \
--date "2026-03-21" \
--time "10:00" \
--duration 90 \
--attendees "user1@example.com,user2@example.com" \
--location "Conference Room A"
Browser auth (local environment):
bash
outlook auth
Device code auth (servers/headless):
bash
outlook auth --device-code
# Visit https://microsoft.com/devicelogin
# Enter the displayed code
from:email@domain.com - Senderto:email@domain.com - Recipientsubject:keyword - Subject linebody:keyword - Email bodyreceived:YYYY-MM-DD - Datehasattachment:yes - Has attachmentsSKILL.md - This documentationoutlook - Main CLI script (Python)README.md - Full documentationToken storage location: ~/.config/outlook-cli/token.json
🔐 Security Warning - Token File Protection:
This file contains sensitive OAuth tokens that grant access to your email and calendar
NEVER share, commit to version control, or expose this file publicly
Set restrictive file permissions immediately after first authentication: bash
chmod 600 ~/.config/outlook-cli/token.jsonVerify permissions:
ls -l ~/.config/outlook-cli/token.jsonshould show-rw-------Add to
.gitignoreif working in a git repository: bashecho ".config/outlook-cli/token.json" >> ~/.gitignoreIf the token file is accidentally exposed, immediately revoke access at: https://account.microsoft.com/privacy/app-access → Remove outlook-cli app
Token features:
When re-authentication is required:
ScenarioReasonChanged Microsoft passwordRefresh token immediately invalidatedToken expired (>90 days)Microsoft refresh token has limited lifetimeManually revoked accessApp permissions revoked in Microsoft account settingsToken file deletedFile loss requires re-authentication
Re-authentication:
bash
outlook auth --device-code
# Visit https://login.microsoft.com/device
# Enter the displayed code
A: Run outlook auth --device-code to re-authenticate.
A: Immediate action required:
rm ~/.config/outlook-cli/token.jsonoutlook auth --device-codechmod 600 ~/.config/outlook-cli/token.jsongit filter-branch or BFG Repo-CleanerA: Use Microsoft Graph API's recurrence field, or create via Outlook web interface.
A: Microsoft Graph API has daily limits. Wait 1-2 hours and retry.