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
~/.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 Type | Folders 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:
# 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
- •List folders - Always start here to understand the mailbox structure
- •Analyze query - What is the user looking for? Sent? Received? Both?
- •Select folders - Pick 1-3 relevant folders based on query type
- •Search with filters - Use date, subject, sender filters to narrow results
- •Read details - Get full content of high-relevance emails
- •Summarize - Present findings focused on the user's context
Commands
# 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
| Option | Description | Example |
|---|---|---|
--folder | Folder name(s) or ID. Required - always specify! | --folder "Inbox" or --folder 117 |
--subject | Subject contains term | --subject "deployment" |
--sender | Sender email contains | --sender "azure" |
--after | Emails after date | --after "2025-01-01" |
--before | Emails before date | --before "2025-01-31" |
--limit | Max results (default: 50) | --limit 10 |
--offset | Skip 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
{
"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
{
"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:
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
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"
- •
List folders:
bash~/.dataops-assistant/bin/outlook-email.sh folders
-> See "Sent Items" (ID: 117, 46 messages) and "Sent Items" (ID: 3, 0 messages)
- •
Analyze: User wants SENT emails -> search Sent Items only. Use ID 117 (has messages).
- •
Search:
bash~/.dataops-assistant/bin/outlook-email.sh search \ --folder 117 \ --subject "deployment" \ --after "2025-01-20" \ --limit 20
- •
Summarize findings focused on deployment topics.