email

Sync, search, read, and send Stanford Office 365 email via the Microsoft Graph API.

4|1|Updated Jun 19, 2019
One-click install
npx skills add https://github.com/rishabh-ranjan/dotfiles --skill email-rishabh-ranjan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: email
Source: https://github.com/rishabh-ranjan/dotfiles/tree/main/.claude/skills/email
Command: npx skills add https://github.com/rishabh-ranjan/dotfiles --skill email-rishabh-ranjan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires msal, requests, and includes scripts (resource) components.

What problem does it solve? Stanford IT does not enable IMAP on Office 365 mailboxes, which blocks standard command-line mail clients. This Skill uses the Microsoft Graph API with device-code authentication to read, search, send, and sync Stanford email to a local Maildir without requiring IMAP access. ## Core Features & Use Cases - Local Maildir Sync: Download all mail folders into ~/Mail/Stanford/ for indexing with notmuch, mutt, or similar tools, with incremental sync based on stored timestamps. - Search and Read: Query the mailbox via the Graph $search endpoint and fetch individual messages by Graph ID, with HTML bodies stripped for terminal display. - Send and Draft: Send plain-text or HTML email with optional CC/BCC directly from the command line. - Use Case: Ask the agent to search your Stanford inbox for messages from a specific sender last week; it syncs the mailbox, runs a notmuch query, and summarizes the matching threads. ## Quick Start Ask the agent to search your Stanford email for recent messages about a specific topic, and it will authenticate, sync, and return matching results.

Frequently Asked Questions about email

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I read Office 365 email from the command line without IMAP?

Use the Microsoft Graph API with device-code authentication to access the mailbox directly. The office365_sync.py script supports search, read, folders, and send commands, and syncs messages to a local Maildir for use with notmuch or mutt.

How do I sync Office 365 mail to a local Maildir?

Run the sync command, which downloads all mail folders into ~/Mail/Stanford/ in Maildir format. Incremental sync uses a stored timestamp in sync_state.json to fetch only new messages, and the --full flag re-checks everything without re-downloading existing files.

Does Microsoft Graph API work if my organization blocks IMAP?

Yes, the Graph API operates over HTTPS and does not depend on IMAP being enabled by the tenant administrator. If the default public client ID is blocked, you can register your own app in the Entra portal and replace the CLIENT_ID in the script.

Why does Office 365 authentication fail with the default client ID?

Some tenants block the default MSAL public client application. The fix is to register your own application at entra.microsoft.com and replace the CLIENT_ID constant in the script, then re-run the auth command.

What are the limitations of syncing email via Microsoft Graph API?

The script does not support calendar access, contacts, or multiple accounts. Refresh tokens can expire after roughly 90 days of inactivity, requiring re-authentication, and Graph search cannot always combine $search with $orderby on all tenants.