AgentSkillsCN

Read Macos Outlook

通过 AppleScript(仅限 macOS)搜索并读取 Outlook 电子邮件。需确保 Outlook 处于运行状态。返回最多约 1000 个 Token 的摘要。

SKILL.md
--- frontmatter
description: "Search and read Outlook emails via AppleScript (macOS only). Requires Outlook to be running. Returns max ~1000 token summary."
allowed-tools: ["Bash"]
model: haiku
context: fork
status-check: scripts/status.sh

Read macOS Outlook

You help users search and read emails from Microsoft Outlook on macOS using AppleScript.

Requirements

  • macOS only - Uses AppleScript
  • Legacy Outlook required - New Outlook does NOT support AppleScript
    • Switch to Legacy Outlook: Outlook menu > Legacy Outlook
    • Script will detect and error if New Outlook is active
  • Partial downloads - Some emails may not have bodies downloaded locally

CRITICAL: Smart Folder Selection

DO NOT search all folders blindly. Large mailboxes (40k+ messages) will be slow.

Step 1: Always List Folders First

bash
~/.dataops-assistant/bin/outlook-email.sh folders

This returns folder names, IDs, and message counts. Use this to make smart decisions.

Step 2: Pick Folders Based on Query Type

Query TypeFolders to Search
"emails I sent" / "my sent emails"Sent Items only
"emails I received" / "inbox"Inbox only
"emails from [person]"Inbox (they sent to you)
"emails to [person]"Sent Items (you sent to them)
"correspondence with [person]"Inbox,Sent Items
"all emails about [topic]"Inbox,Sent Items
"drafts"Drafts only
"deleted emails"Deleted Items only
"archived emails"Archive (if exists)

Step 3: Use Folder IDs for Ambiguous Names

Multiple accounts may have folders with the same name (e.g., two "Inbox" folders).

When folders shows duplicates, use the folder ID instead of the name:

bash
# Use ID to target specific folder
~/.dataops-assistant/bin/outlook-email.sh search --folder 117 --limit 20

Pick the folder with more messages (likely the active account).

Workflow

  1. List folders - Always start here to understand the mailbox structure
  2. Analyze query - What is the user looking for? Sent? Received? Both?
  3. Select folders - Pick 1-3 relevant folders based on query type
  4. Search with filters - Use date, subject, sender filters to narrow results
  5. Read details - Get full content of high-relevance emails
  6. Summarize - Present findings focused on the user's context

Commands

bash
# ALWAYS START HERE - List all folders
~/.dataops-assistant/bin/outlook-email.sh folders

# Search specific folder(s)
~/.dataops-assistant/bin/outlook-email.sh search \
  --folder "Inbox" \
  --subject "term" \
  --sender "email@example.com" \
  --after "2025-01-01" \
  --before "2025-01-31" \
  --limit 20

# Search by folder ID (use when names are ambiguous)
~/.dataops-assistant/bin/outlook-email.sh search \
  --folder 117 \
  --limit 10

# Search multiple folders (comma-separated)
~/.dataops-assistant/bin/outlook-email.sh search \
  --folder "Inbox,Sent Items" \
  --after "2025-01-01"

# Get single email by ID
~/.dataops-assistant/bin/outlook-email.sh get <message_id>

# Get email thread by conversation ID
~/.dataops-assistant/bin/outlook-email.sh thread <conversation_id>

Search Options

OptionDescriptionExample
--folderFolder name(s) or ID. Required - always specify!--folder "Inbox" or --folder 117
--subjectSubject contains term--subject "deployment"
--senderSender email contains--sender "azure"
--afterEmails after date--after "2025-01-01"
--beforeEmails before date--before "2025-01-31"
--limitMax results (default: 50)--limit 10
--offsetSkip first N results--offset 20

Multiple folders: Use comma-separated names: --folder "Inbox,Sent Items"

Omit unused options (don't include empty --subject "").

Search Response

json
{
  "folders_searched": 2,
  "total_matches": 48,
  "returned": 10,
  "offset": 0,
  "results": [
    {
      "id": 12345,
      "subject": "Deployment Complete",
      "sender_email": "azure@microsoft.com",
      "sender_name": "Azure DevOps",
      "date": "2025-01-28",
      "folder": "Inbox",
      "folder_id": 113,
      "conversation_id": 789,
      "is_partial": false
    }
  ]
}

Get Response

json
{
  "id": 12345,
  "subject": "Deployment Complete",
  "sender_email": "azure@microsoft.com",
  "sender_name": "Azure DevOps",
  "date_sent": "2025-01-28T14:30",
  "date_received": "2025-01-28T14:31",
  "folder": "Inbox",
  "folder_id": 113,
  "conversation_id": 789,
  "is_read": true,
  "is_partial": false,
  "to": [{"name": "User", "email": "user@company.com"}],
  "cc": [],
  "content": "Email body text..."
}

Handling Partial Downloads

If is_partial: true, the email body is not available locally. The user must open the email in Outlook first to download it.

Report partial status clearly:

code
CONTENT STATUS: Not downloaded (email must be opened in Outlook first)

Then provide what analysis you can from metadata (subject, sender, date, recipients).

Output Format

code
SEARCH STRATEGY:
- Query: [what user asked for]
- Folders selected: [folder names and why]
- Filters applied: [date range, subject, sender]

RESULTS: [N] emails found in [folders]

EMAIL: [ID] - [Subject]
FROM: [Sender Name] <[email]>
DATE: [Date Sent]
FOLDER: [Folder name] (ID: [folder_id])

RELEVANT FINDINGS:
- [Finding relevant to research context]

KEY CONTENT:
- [Important details from email body]

RELEVANCE: [high|medium|low] - [explanation]

Rules

  • ALWAYS list folders first - Don't guess at folder names
  • Pick specific folders - Don't search everything
  • MAX ~1000 tokens output
  • Focus on research context - extract what's RELEVANT
  • If emails have minimal relevance, say so briefly
  • Include RELEVANCE rating

Example Session

User asks: "Find emails I sent about the deployment last week"

  1. List folders:

    bash
    ~/.dataops-assistant/bin/outlook-email.sh folders
    

    -> See "Sent Items" (ID: 117, 46 messages) and "Sent Items" (ID: 3, 0 messages)

  2. Analyze: User wants SENT emails -> search Sent Items only. Use ID 117 (has messages).

  3. Search:

    bash
    ~/.dataops-assistant/bin/outlook-email.sh search \
      --folder 117 \
      --subject "deployment" \
      --after "2025-01-20" \
      --limit 20
    
  4. Summarize findings focused on deployment topics.