Source: https://cli.nylas.com/guides/list-outlook-emails

# 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](https://cli.nylas.com/authors/nick-barraclough) Product Manager

Reviewed by [Qasim Muhammad](https://cli.nylas.com/authors/qasim-muhammad)

Updated April 26, 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

```bash
# 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](https://cli.nylas.com/guides/getting-started).

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

```bash
nylas auth config
# Paste your API key when prompted

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

## 2. List, search, and read emails

```bash
# 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:

```bash
# 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:

```bash
# 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:

```bash
# 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:

```bash
# 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:

| Step | Microsoft Graph API | Nylas CLI |
| --- | --- | --- |
| Register app | Azure AD app registration (portal.azure.com) | Not required |
| Permissions | `Mail.Read` scope + admin consent for org accounts | Handled by Nylas dashboard |
| Auth flow | MSAL library, token acquisition, refresh handling | `nylas auth config` |
| Code | REST calls or MS Graph SDK — 40+ lines minimum | Zero code |
| List emails | `GET /me/messages` with Bearer token | `nylas email list` |
| Response format | Microsoft proprietary JSON (not MIME) | Normalized JSON across all providers |
| Pagination | Follow `@odata.nextLink` manually | `--limit` flag |
| Search | `$search` or `$filter` OData params | `nylas email search "query"` |
| Rate limits | 10,000 req / 10 min per mailbox — handle 429s yourself | Handled automatically with backoff |
| Shared mailboxes | `Mail.Read.Shared` + admin consent | Separate 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

- [Send Outlook email from the CLI](https://cli.nylas.com/guides/send-outlook-email-cli) — send, schedule, and attach files from your Outlook account
- [Manage Outlook calendar from the CLI](https://cli.nylas.com/guides/manage-outlook-calendar-cli) — create events, check availability, book rooms
- [Send email from the terminal](https://cli.nylas.com/guides/send-email-from-terminal) — send, schedule, and track emails
- [List Gmail emails](https://cli.nylas.com/guides/list-gmail-emails) — same workflow for Google
- [List Yahoo Mail emails](https://cli.nylas.com/guides/list-yahoo-emails) — same workflow for Yahoo
- [List iCloud Mail emails](https://cli.nylas.com/guides/list-icloud-emails) — same workflow for Apple
- [List IMAP emails](https://cli.nylas.com/guides/list-imap-emails) — works with Fastmail, Zoho, and more
- [List Exchange emails](https://cli.nylas.com/guides/list-exchange-emails) — same workflow for Exchange
- [Give AI agents email access via MCP](https://cli.nylas.com/guides/ai-agent-email-mcp) — connect Claude, Cursor, or VS Code to your inbox
- [Full command reference](https://cli.nylas.com/docs/commands) — every flag and subcommand documented
- [Microsoft Graph: List messages](https://learn.microsoft.com/en-us/graph/api/user-list-messages) — the canonical Outlook / Microsoft 365 mail-listing endpoint
- [Microsoft Graph: OData query parameters](https://learn.microsoft.com/en-us/graph/query-parameters) — $filter, $search, and $select semantics behind the CLI's flags
