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

# Outlook CLI: Manage Mail and Calendar

You want to read your Outlook inbox or send a message from a script, and Microsoft says: register an Azure AD app first. There's a shorter route. One OAuth login connects Microsoft 365 and Outlook.com, then mail and calendar are terminal commands that return JSON. This is the hub for working with Outlook from the command line.

Written by [Nick Barraclough](https://cli.nylas.com/authors/nick-barraclough) Product Manager

Updated June 8, 2026

> **TL;DR:** Authenticate once with `nylas auth login --provider microsoft`, then list, search, and send Outlook mail and manage the calendar from the terminal — no Azure app registration, no Graph permissions, no PowerShell module. It works on macOS, Linux, and Windows, against both Microsoft 365 work accounts and personal Outlook.com.

Command references used in this guide: [`nylas auth login`](https://cli.nylas.com/docs/commands/auth-login), [`nylas email list`](https://cli.nylas.com/docs/commands/email-list), [`nylas email send`](https://cli.nylas.com/docs/commands/email-send), and [`nylas calendar events list`](https://cli.nylas.com/docs/commands/calendar-events-list).

## How do you use Outlook from the command line?

You use Outlook from the command line by connecting the account once over OAuth, then running mail and calendar commands. The `nylas auth login --provider microsoft` command opens a browser, you approve access, and the grant is stored in your system keyring. After that, `nylas email list` and `nylas calendar events list` read directly from Outlook — the first message appears in about two minutes from a cold install.

This works the same on a Mac laptop, a Linux CI runner, and Windows, which matters because Outlook ships no first-party CLI of its own. The token refreshes automatically, so a script written today still runs in a month without a re-login. Every command accepts `--json` for piping into `jq`, Python, or an AI agent.

```bash
# Install (other methods at /guides/getting-started)
brew install nylas/nylas-cli/nylas

# Connect the Outlook account (opens a browser once)
nylas auth login --provider microsoft

# Read the 10 most recent messages
nylas email list
```

## Why is Outlook hard to script directly?

Scripting Outlook directly runs into two Microsoft decisions. First, [Basic Authentication for Exchange Online](https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online) was deprecated in October 2022, so IMAP and SMTP with a plain username and password no longer work for Microsoft 365 mailboxes — and personal Outlook.com followed in September 2024. Second, the supported path is the Microsoft Graph API, which requires registering an application in Azure Active Directory before the first call.

That registration is the wall most people hit. You create an app, choose delegated or application permissions, request scopes like `Mail.Read` and `Mail.Send`, and — for unattended access — get admin consent across the tenant. The [Graph app registration docs](https://learn.microsoft.com/en-us/graph/auth-register-app-v2) run several pages. The CLI handles the OAuth exchange for you, so a single login replaces the whole Azure setup.

## How do you read and send Outlook email from the CLI?

Once the account is connected, `nylas email list` reads the inbox and `nylas email send` sends from the user's own Outlook address. Search uses Microsoft's own query support behind the scenes, so `nylas email search` returns server-side matches rather than downloading and filtering locally — the same mailbox the [Microsoft Graph mail API](https://learn.microsoft.com/en-us/graph/api/resources/mail-api-overview) exposes. The `--json` flag turns any of these into structured output for a pipeline.

Outlook organizes mail with categories and folders rather than Gmail-style labels, and the CLI maps to that model with `--folder`. Sending goes through Microsoft's own SMTP infrastructure, so the message inherits the tenant's SPF and DKIM — no separate relay to configure. For a deeper walkthrough see the dedicated [send Outlook email](https://cli.nylas.com/guides/send-outlook-email-cli) and [list Outlook emails](https://cli.nylas.com/guides/list-outlook-emails) guides.

```bash
# Search the Outlook mailbox (server-side)
nylas email search "from:finance@contoso.com" --json --limit 20

# Read a specific folder
nylas email list --folder "Archive" --limit 25

# Send from the user's own Outlook address
nylas email send --to partner@example.com \
  --subject "Q3 review" \
  --body "Numbers are ready for your sign-off."
```

## How do you manage the Outlook calendar from the CLI?

The `nylas calendar events list` command reads Outlook calendar events, defaulting to the next 7 days, and `--days` widens or narrows that window. Because the same OAuth grant covers mail and calendar, there's no second login — the account you connected for email already exposes its calendar. Events return as JSON with attendees, times, and conferencing links intact.

This is where the CLI's unified model pays off: checking availability across an Outlook calendar uses the identical command you'd run against a Google calendar, only the connected grant differs. Creating invites and handling recurring events is covered in the [Outlook calendar guide](https://cli.nylas.com/guides/manage-outlook-calendar-cli). The events feed also drives scheduling automations without touching Graph's calendar endpoints.

```bash
# Next 14 days of Outlook events
nylas calendar events list --days 14

# Machine-readable feed for a script
nylas calendar events list --days 30 --json \
  | jq -r '.[] | "\(.when.start_time)\t\(.title)"'
```

## What are the options for Outlook on the command line?

Four approaches reach Outlook from a terminal, and they differ mostly in setup cost. The Graph API is the most capable but needs an Azure app. PowerShell's Microsoft Graph module suits Windows admins. IMAP no longer works for most accounts since the 2022 Basic Auth retirement. The Nylas CLI trades some Graph-specific depth for a single OAuth login that works cross-platform.

| Approach | Setup | Cross-platform | Best for |
| --- | --- | --- | --- |
| Graph API | Azure app + scopes | Yes | Full-featured custom apps |
| Graph PowerShell | Module install + consent | Mostly Windows | Tenant administration |
| IMAP/SMTP | Blocked since Oct 2022 | N/A | Legacy only |
| Nylas CLI | One OAuth login | macOS / Linux / Windows | Scripts, cron, AI agents |

If you administer a whole tenant, the Graph PowerShell module is the right tool. For a developer who wants to read one mailbox, send a notification, or check a calendar from a script, the OAuth login is faster. Windows admins migrating off legacy cmdlets should read the [Office 365 PowerShell guide](https://cli.nylas.com/guides/office365-email-powershell).

## Next steps

- [List Outlook emails](https://cli.nylas.com/guides/list-outlook-emails) — read, filter, and export the inbox as JSON
- [Send Outlook email from the CLI](https://cli.nylas.com/guides/send-outlook-email-cli) — send from the user's own address
- [Manage the Outlook calendar](https://cli.nylas.com/guides/manage-outlook-calendar-cli) — events, availability, and invites
- [Outlook OAuth for AI agents](https://cli.nylas.com/guides/outlook-oauth-ai-agents) — Graph scopes and unattended access
- [Full command reference](https://cli.nylas.com/docs/commands) — every flag and subcommand documented
