CLI tool for interacting with Microsoft Outlook email via the Microsoft Graph API. Supports listing, reading, sending, replying, drafts, and folder management.
- Node.js 18+
- An Azure AD app registration with Microsoft Graph permissions (Mail.Read, Mail.ReadWrite, Mail.Send, User.Read)
-
Clone and install:
cd ~/tools/outlook-cli npm install npm run build npm link
-
Configure credentials in
.env(see.env.example):OUTLOOK_CLIENT_ID=your-app-client-id OUTLOOK_CLIENT_SECRET=your-client-secret OUTLOOK_TENANT_ID=your-tenant-id OUTLOOK_REDIRECT_URI=http://localhost:3000/callback -
Authenticate:
outlook-cli auth
This opens a browser window for Microsoft OAuth2 login. Tokens are saved to
tokens/tokens.jsonand auto-refreshed.
outlook-cli auth— Start OAuth2 flowoutlook-cli me— Get current user profile
outlook-cli emails list— List inbox emailsoutlook-cli emails get --id ID— Get full emailoutlook-cli emails send --to ADDR --subject SUBJ --text BODY— Send emailoutlook-cli emails reply --id ID --text BODY— Reply to emailoutlook-cli emails move --id ID --folder FOLDER_ID— Move emailoutlook-cli emails delete --id ID— Delete emailoutlook-cli emails read --id ID— Mark as readoutlook-cli emails unread --id ID— Mark as unreadoutlook-cli emails attachments --id ID— List attachments (id, name, type, size)outlook-cli emails download --id ID [--attachment-id ATT_ID] [--out PATH]— Download attachment(s) to disk
outlook-cli drafts list— List draftsoutlook-cli drafts create --to ADDR --subject SUBJ --text BODY— Create draftoutlook-cli drafts reply --id ID— Create reply draftoutlook-cli drafts update --id ID --subject SUBJ— Update draftoutlook-cli drafts send --id ID— Send draftoutlook-cli drafts delete --id ID— Delete draft
outlook-cli folders list— List mail foldersoutlook-cli folders create --name NAME— Create folder
- Always use
--htmlinstead of--textwhen sending, replying, or creating drafts. Plain text (--text) renders without line breaks in Outlook — newlines are ignored. Use<p>tags for paragraphs and<br>for line breaks. Example:outlook-cli drafts create --to "someone@example.com" --subject "Hello" \ --html '<p>Hi there,</p><p>Here is my message.</p><p>Thanks!</p>'
All commands output JSON to stdout:
{"ok": true, "data": { ... }}
{"ok": false, "error": "message", "code": "ERROR_CODE"}Uses the Microsoft Graph REST API v1.0 with OAuth2 delegated permissions. The app is registered in Azure AD (Microsoft Entra ID) with multi-tenant + personal account support. Tokens are stored locally and auto-refreshed using the refresh token.