Agent skill
Microsoft Graph Email Search
Patterns for finding and exporting mail via Microsoft Graph (delegated auth), with safe defaults and paging/retry guidance.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/graph-email-search
SKILL.md
When to use
- The user asks to find, export, or summarize emails (sent or received) using Microsoft Graph.
Preconditions
- Delegated auth is configured (see docs/GRAPH_AUTH_REPLICATION_GUIDE.md).
- App permissions include Mail scopes:
- Minimal read-only:
Mail.Read - If you also need move/label/update:
Mail.ReadWrite
- Minimal read-only:
Recommended approach (safe + repeatable)
- Prefer read-only endpoints first.
- Write exports to a run-local or ignored location:
- Repo-root temp:
tmp/...(ignored) - Run-local:
runs/<RUN_ID>/exports/...
- Repo-root temp:
- Use the repo utility:
python -m agent_tools.graph.export_sent_mail --to <RECIPIENT_EMAIL> --include-cc --out-dir tmp/mail_exports_<slug>
Query strategy
Sent mail to a recipient
- Start with SentItems:
GET /me/mailFolders/SentItems/messages
Filtering vs search
- Try
$filterfirst (deterministic), but be ready for tenant-specific limitations. - If Graph returns filter errors (e.g.,
ErrorInvalidUrlQueryFilter), fall back to$search:- Include header:
ConsistencyLevel: eventual - Example:
$search="recipients:<email>"
- Include header:
Pagination
- Respect
@odata.nextLinkuntil exhausted. - NextLink is typically an absolute URL; your HTTP client should accept absolute URLs directly.
Output hygiene
- The exported document may contain sensitive content.
- Do not commit exports to git.
- Avoid pasting large email bodies into chat unless explicitly requested.
Troubleshooting
- 401: token expired → retry once with a fresh token.
- 403: missing Mail scopes or missing admin consent.
- Empty results: confirm you’re searching SentItems vs Inbox and whether you included Cc.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?