Guide

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 Product Manager

VerifiedCLI 3.1.16 · Outlook · last tested June 8, 2026

Command references used in this guide: nylas auth login, nylas email list, nylas email send, and nylas 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.

# 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 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 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 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 and list Outlook emails guides.

# 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. The events feed also drives scheduling automations without touching Graph's calendar endpoints.

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

ApproachSetupCross-platformBest for
Graph APIAzure app + scopesYesFull-featured custom apps
Graph PowerShellModule install + consentMostly WindowsTenant administration
IMAP/SMTPBlocked since Oct 2022N/ALegacy only
Nylas CLIOne OAuth loginmacOS / Linux / WindowsScripts, 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.

Next steps