Guide

List Outlook Emails from Terminal (No Graph API)

Microsoft 365 has 400+ million paid seats, but reading your own inbox from a terminal still requires Azure AD app registration, MSAL tokens, and Graph API calls. The Nylas CLI handles all of that — authenticate once, then list, search, and read Outlook emails with one command. Works with Gmail, Outlook, Exchange, Yahoo, iCloud, and IMAP.

Written by Nick Barraclough Product Manager

Reviewed by Qasim Muhammad

VerifiedCLI 3.1.1 · Outlook.com, Microsoft 365 · last tested April 11, 2026

Why reading Outlook email from a terminal is harder than it should be

Microsoft 365 has over 400 million paid seats, according to Microsoft's FY2024 earnings report. It's the most widely deployed business email platform in the world. Yet reading your own inbox from the command line requires a surprising amount of setup.

The Graph API is the only supported path since Microsoft deprecated Basic Auth for Exchange Online in October 2022. To make a single GET /me/messages call, you need to register an app in Azure AD, configure Mail.Read permissions, implement MSAL token acquisition with refresh handling, and parse Microsoft's proprietary JSON format (not standard MIME). According to Microsoft's Graph API throttling guidance, each mailbox is limited to 10,000 requests per 10 minutes — so you also need retry logic for 429 responses.

EWS (Exchange Web Services) is still around, but Microsoft announced its deprecation for Exchange Online in October 2026 (announcement MC862873). The az CLI doesn't have email commands. PowerShell's Get-MailboxFolderPermission requires Exchange Online management modules and admin access. None of these give you a clean, portable workflow.

1. Install and authenticate

# Install via Homebrew (macOS / Linux)
brew install nylas/nylas-cli/nylas

Other install methods (shell script, PowerShell, Go) are covered in the getting started guide.

Head to dashboard-v3.nylas.com, create an application, and connect your Microsoft 365 or Outlook.com account. Then configure the CLI:

nylas auth config
# Paste your API key when prompted

nylas auth whoami
# => Authenticated as you@company.com (Microsoft)

2. List, search, and read emails

# Recent emails
nylas email list
nylas email list --limit 10
nylas email list --unread

# Search by keyword, sender, or date range
nylas email search "quarterly report" --limit 5
nylas email search "from:manager@company.com"
nylas email search "after:2026-01-01 before:2026-02-01"

# Read a specific message (IDs shown in list output)
nylas email read msg_abc123
nylas email read msg_abc123 --mime

3. JSON output for scripting

Add --json to any command and pipe into jq, a script, or an AI agent:

# Count unread emails
nylas email list --unread --json | jq length

# Extract subjects
nylas email list --limit 5 --json | jq '.[].subject'

# Filter Teams/SharePoint notifications
nylas email list --json \
  | jq '[.[] | select(.from[0].email | test("teams|sharepoint"; "i"))]' \
  | jq length

4. Focused Inbox vs Other

Outlook splits incoming mail into Focused (messages it considers important) and Other (everything else). The Graph API exposes this via the inferenceClassification property, but it requires a separate $filter param and doesn't map to a folder. The CLI lets you work with both through folders:

# List all folders — Focused Inbox shows as a folder attribute
nylas email folders list

# List emails in specific Outlook folders
nylas email list --folder "Inbox"
nylas email list --folder "Sent Items"
nylas email list --folder "Archive"
nylas email list --folder "Junk Email"
nylas email list --folder "Drafts"

5. Shared mailboxes and delegated access

Microsoft 365 organizations often use shared mailboxes for team aliases like support@ or billing@. The Graph API requires GET /users/{id}/messages with Mail.Read.Shared permissions and admin consent to access these. With the CLI, connect the shared mailbox as a separate grant in the Nylas dashboard, then switch between accounts:

# List grants to see all connected mailboxes
nylas auth list

# Work with a shared mailbox (connected as a separate grant)
nylas email list <shared-mailbox-grant-id>

Delegated access works the same way — connect the delegated mailbox as its own grant.

6. Outlook categories and flags

Outlook supports color-coded categories and follow-up flags — features that don't exist in Gmail or Yahoo. The Graph API returns categories as an array of strings on each message object. You can filter by category using search:

# Search for emails with a specific category
nylas email search "category:Red"

# Combine category with other filters
nylas email search "category:Blue from:cfo@company.com" --limit 10

# Export categorized emails as JSON for reporting
nylas email list --json | jq '[.[] | select(.categories[]? == "Project Alpha")]'

7. Microsoft Graph API vs Nylas CLI

Side-by-side comparison for listing emails. The Graph API numbers are based on Microsoft Learn documentation for the /me/messages endpoint:

StepMicrosoft Graph APINylas CLI
Register appAzure AD app registration (portal.azure.com)Not required
PermissionsMail.Read scope + admin consent for org accountsHandled by Nylas dashboard
Auth flowMSAL library, token acquisition, refresh handlingnylas auth config
CodeREST calls or MS Graph SDK — 40+ lines minimumZero code
List emailsGET /me/messages with Bearer tokennylas email list
Response formatMicrosoft proprietary JSON (not MIME)Normalized JSON across all providers
PaginationFollow @odata.nextLink manually--limit flag
Search$search or $filter OData paramsnylas email search "query"
Rate limits10,000 req / 10 min per mailbox — handle 429s yourselfHandled automatically with backoff
Shared mailboxesMail.Read.Shared + admin consentSeparate grant, same commands

8. Microsoft 365 deployment notes

Things that trip up Microsoft 365 users specifically:

  • Conditional access policies — if your org enforces device compliance or IP restrictions, your IT admin may need to allowlist the Nylas connection
  • GCC and GCC High tenants — US government cloud tenants use separate Graph API endpoints; check with your admin before connecting
  • Retention policies — Microsoft 365 compliance retention policies can prevent message deletion even if the CLI command succeeds. The message reappears after sync
  • Teams and SharePoint notifications — filter these with nylas email search "from:noreply@email.teams.microsoft.com"

Next steps