Guide

Outlook CLI: List Emails from Terminal (No Graph API)

Use an Outlook CLI to read, search, and filter Microsoft 365 email from terminal. The raw Graph API path requires Azure AD app registration, MSAL tokens, permissions, and retry logic. Nylas CLI handles that setup behind one command and uses the same workflow across Gmail, 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

How do you use an Outlook CLI to read email from terminal?

Use nylas email list, nylas email search, and nylas email read after connecting your Outlook or Microsoft 365 mailbox. The CLI gives you a terminal Outlook workflow without registering an Azure AD app or writing Microsoft Graph API code.

For an Outlook email command line workflow, this means one set of commands for listing, searching, and reading mail across Outlook.com and Microsoft 365 accounts.

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

Installing the Nylas CLI and connecting an Outlook account takes under 2 minutes. The CLI authenticates via API key, so you don't need to register an Azure AD app, configure MSAL, or handle token refresh yourself. One brew install command and one API key paste gets you from zero to listing emails.

Homebrew is the fastest install path on macOS and Linux. The formula pulls the latest release binary and verifies its SHA-256 checksum automatically.

# 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.

After installing, head to dashboard-v3.nylas.com, create an application, and connect your Microsoft 365 or Outlook.com account. The dashboard handles OAuth2 consent and token storage. Then configure the CLI with your API key:

nylas auth config
# Paste your API key when prompted

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

2. List, search, and read emails

The Nylas CLI exposes three email subcommands — list, search, and read — that cover the same surface as 8 different Graph API endpoints. Each command returns results in under 1 second for typical mailboxes. The list command shows recent messages by default, while search accepts keyword, sender, and date-range filters that map to Outlook's server-side search index.

The following examples show common patterns for listing, filtering, and reading Outlook email. The --limit flag controls how many results return, and --unread restricts output to messages you haven't opened.

# 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

Every Nylas CLI email command accepts a --json flag that outputs normalized JSON instead of the default table view. This JSON format is consistent across all 6 supported providers — Gmail, Outlook, Exchange, Yahoo, iCloud, and IMAP — so scripts written for one provider work unchanged with another. The output pipes directly into jq, shell scripts, or AI agent tool-use flows.

The examples below show three common scripting patterns: counting unread messages, extracting subject lines, and filtering out automated notifications from Microsoft Teams and SharePoint. Microsoft 365 accounts typically receive 15-30 automated notification emails per day from Teams alone, making programmatic filtering useful for inbox analytics.

# 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's Focused Inbox uses machine learning to separate important messages from low-priority ones, and Microsoft reports that it reduces time spent triaging email by up to 50% for active users. The Graph API exposes this classification through the inferenceClassification property, but accessing it requires a separate $filter parameter and doesn't map to a standard folder. The Nylas CLI exposes Outlook's folder structure directly, so you can list messages from any folder including Focused, Inbox, Sent Items, and Junk Email.

The nylas email folders list command shows every folder in the mailbox, including system folders that Outlook creates automatically. The --folder flag on nylas email list filters results to a single folder by name.

# 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

Shared mailboxes are a common pattern in Microsoft 365 organizations — Microsoft's own documentation estimates that the average enterprise tenant has 5-10 shared mailboxes for team aliases like support@ or billing@. Accessing a shared mailbox through the Graph API requires GET /users/{id}/messages with Mail.Read.Shared permissions and tenant admin consent. The Nylas CLI simplifies this by treating each shared mailbox as a separate grant, so you switch between personal and shared mailboxes with the same commands.

Connect the shared mailbox as a separate grant in the Nylas dashboard. Then use nylas auth list to see all connected mailboxes and pass the grant ID to any email command. Delegated access works the same way.

# 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>

6. Outlook categories and flags

Outlook supports up to 25 color-coded categories and follow-up flags per message — features that have no equivalent in Gmail or Yahoo Mail. Categories are one of the most used organizational features in enterprise Outlook deployments, according to Microsoft's productivity research. The Graph API returns categories as an array of strings on each message object, but filtering by category requires building an OData $filter expression. The Nylas CLI exposes category filtering through its search syntax.

The search command accepts category names directly. You can also combine category filters with sender and keyword queries, or pipe JSON output through jq for custom category-based reports.

# 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

The Microsoft Graph API requires a minimum of 40 lines of code and 4 separate configuration steps to list emails from an Outlook mailbox. The Nylas CLI reduces that to a single command with zero application code. The following table compares each step side by side, with Graph API details sourced from 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

Microsoft 365 tenants have organization-level policies that can affect how external tools connect to mailboxes. These policies exist across all 400+ million paid seats and vary significantly by industry — healthcare and government tenants enforce stricter conditional access than most commercial deployments. The following issues are specific to Microsoft 365 and don't apply to personal Outlook.com accounts.

  • 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