# Share your email with your agent

Source: https://developer.nylas.com/docs/v3/getting-started/agent-email/

Give your agent full read/write access to the inbox you already use — a personal Gmail, a shared Outlook mailbox, or any IMAP account. Messages the agent sends come from your address, and replies land in your inbox. The Nylas CLI handles provider auth and returns structured JSON so your agent can drive every operation from shell commands.

If you'd rather the agent have its own dedicated mailbox (so replies don't clutter your inbox), see [Give your agent its own email](/docs/v3/getting-started/agent-own-email/).

## Prerequisites

Make sure the CLI is installed and authenticated against the account you want to share. If not, follow the [AI agents quickstart](/docs/v3/getting-started/cli-for-agents/) first.

```bash
nylas auth whoami --json
```

## Read email

List recent messages. Always pass `--json` for structured output and `--limit` to control token consumption.

```bash
nylas email list --limit 5 --json
```

List only unread messages:

```bash
nylas email list --unread --limit 10 --json
```

Read the full content of a specific message:

```bash
nylas email read <MESSAGE_ID> --json
```

## Send email

Send a message on behalf of the connected user. Always pass `--yes` to skip the confirmation prompt.

```bash
nylas email send \
  --to "recipient@example.com" \
  --subject "Weekly status update" \
  --body "Here are this week's highlights..." \
  --yes
```

Send with CC and scheduled delivery:

```bash
nylas email send \
  --to "alice@example.com" \
  --cc "bob@example.com" \
  --subject "Meeting notes" \
  --body "Attached are the notes from today's sync." \
  --schedule "tomorrow 9am" \
  --yes
```

## Search email

Search uses the provider's native search syntax (Gmail search operators, Microsoft KQL), so queries like `from:` and `has:attachment` work as expected.

```bash
nylas email search "from:billing@stripe.com" --limit 5 --json
```

```bash
nylas email search "has:attachment subject:invoice" --limit 10 --json
```

### Manage messages

```bash
# Mark a message as read
nylas email mark read <MESSAGE_ID>

# Star/flag a message
nylas email mark starred <MESSAGE_ID>

# Delete a message
nylas email delete <MESSAGE_ID> --yes
```

### Example: inbox triage workflow

Here's a realistic pattern for an agent that triages an inbox:

```bash
# 1. Get unread messages
nylas email list --unread --limit 20 --json

# 2. Read the full content of a message that looks important
nylas email read <MESSAGE_ID> --json

# 3. (Agent classifies the message using its LLM)

# 4. Reply to urgent messages
nylas email send \
  --to "sender@example.com" \
  --subject "Re: Server outage" \
  --body "Looking into this now. Will update within the hour." \
  --yes

# 5. Mark processed messages as read
nylas email mark read <MESSAGE_ID>
```

### Using MCP instead

If your agent supports [Model Context Protocol](https://modelcontextprotocol.io/) (Claude Code, Cursor, Windsurf, VS Code, Codex CLI), you can register the CLI as an MCP server instead of calling commands directly:

```bash
nylas mcp install --assistant claude-code
```

This gives your agent typed tools for email operations without subprocess calls. See the [MCP docs](/docs/dev-guide/mcp/) for details.

## What's next

- **[Give your agent its own email](/docs/v3/getting-started/agent-own-email/)** -- give the agent a dedicated `agent@yourdomain.com` mailbox via a Nylas Agent Account
- **[Share your calendar with your agent](/docs/v3/getting-started/agent-calendar/)** -- manage events and check availability on your connected calendar
- **[Give your agent call recordings](/docs/v3/getting-started/agent-notetaker/)** -- record meetings and get transcripts
- **[AI agents quickstart](/docs/v3/getting-started/cli-for-agents/)** -- full CLI setup and command reference
- **[CLI guides](https://cli.nylas.com/guides)** -- 85+ step-by-step guides for email, calendar, and more