> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# On new email

> Start an automation when a message is created in an Outlook Inbox.

`onNewEmail` subscribes to messages created in the connected account's Inbox.
Use it for inbound-mail routing, notification, and follow-up workflows.

## Example

```ts automations/process-outlook-mail.automation.ts theme={null}
import { automation } from "automate.ax"
import { markAsRead, onNewEmail } from "automate.ax/outlook"

export default automation("Process Outlook mail", () => {
  const email = onNewEmail()
  markAsRead({ messageId: email.messageId })
})
```

## Options

Optional `account: string | IntegrationAccountReference<"microsoft">`
statically selects the mailbox and defaults to the project Microsoft binding.
A runtime signal cannot select a trigger account.

## Trigger data

Returns `Signal<OutlookMessage>` with `messageId`, subject, body, preview,
recipients, sender, timestamps, conversation and folder IDs, read/draft and
attachment state, categories, importance, flag, Focused Inbox classification,
web link, and ETag where Microsoft supplies them. Recipient arrays and
categories default to `[]`; subject defaults to an empty string.

The trigger watches message creation in Inbox. It reports `hasAttachments` but
does not embed attachment data; call `listAttachments` with `messageId` to read
attachments.
