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

# Outlook

> Virtualize an Outlook mailbox through Microsoft Graph.

![](https://mintcdn.com/struktoai/F9Lv_nTaj6By6crk/images/python-logo.svg?fit=max\&auto=format\&n=F9Lv_nTaj6By6crk\&q=85\&s=cf5b268d330f7db46ea5cf6083f309a1)

Node.js

Browser

![](https://mintcdn.com/struktoai/CsxMCKUyfoQQJYHB/images/cloudflare-logo.svg?fit=max\&auto=format\&n=CsxMCKUyfoQQJYHB\&q=85\&s=23668457afa14abb3b0db0f5b9c0541a)

An Outlook mailbox becomes a folder tree, read only: each mail folder a
folder of days, each message Microsoft Graph's own message JSON and its
attachments a folder beside it.

## Setup

The mount needs a Microsoft Graph access token with `Mail.Read`. A delegated
token reads the signed-in user's mailbox; an app-only token names the
mailbox with `user_id`.

> [accordion] Quick token (Graph Explorer)
>
> The fastest way to try it. The token lasts about an hour.
>
> 1. Open [Graph Explorer](https://developer.microsoft.com/graph/graph-explorer)
>    and sign in.
> 2. Run `GET /me/mailFolders` and consent to `Mail.Read` when asked.
> 3. Open the **Access token** tab and copy the token.

> [accordion] Device-code token (own app registration)
>
> A delegated token from an app registration. The first sign-in is
> interactive, so this is a development bootstrap, not an unattended
> credential.
>
> 1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go
>    to **Entra ID** > **App registrations** > **New registration**.
>
> 2. Under **Authentication**, set **Allow public client flows** to **Yes**.
>
> 3. Under **API permissions** > **Microsoft Graph** > **Delegated
>    permissions**, add `Mail.Read`.
>
> 4. Request a device code with the **Application (client) ID** and the
>    **Directory (tenant) ID** from the registration's **Overview**, open
>    `https://microsoft.com/devicelogin` and enter the `user_code` it
>    prints. A registration that accepts accounts in any tenant can use
>    `common` for the tenant:
>
>    ```bash theme={null}
>    curl -s -X POST "https://login.microsoftonline.com/$TENANT_ID/oauth2/v2.0/devicecode" \
>      -d "client_id=$CLIENT_ID" \
>      -d "scope=Mail.Read offline_access"
>    ```
>
> 5. After signing in, exchange the `device_code` for tokens:
>
>    ```bash theme={null}
>    curl -s -X POST "https://login.microsoftonline.com/$TENANT_ID/oauth2/v2.0/token" \
>      -d "grant_type=urn:ietf:params:oauth:grant-type:device_code" \
>      -d "client_id=$CLIENT_ID" \
>      -d "device_code=$DEVICE_CODE"
>    ```
>
> Mirage does not refresh Microsoft tokens itself: a long-running program
> passes a callable as `access_token` that returns a fresh token.

```bash theme={null}
export MS_GRAPH_MAIL_TOKEN=eyJ0eXAi...
```

## Connect

> [tab] YAML
>
> ```yaml workspace.yaml theme={null}
> mounts:
>   /outlook:
>     vfs: outlook
>     mode: read
>     config:
>       access_token: ${MS_GRAPH_MAIL_TOKEN}
> ```
>
> ```bash theme={null}
> mirage workspace create workspace.yaml --id mail
> mirage shell -w mail -c 'ls /outlook'
> ```

> [tab] Python
>
> ```python theme={null}
> import os
>
> from mirage import MountMode, Workspace
> from mirage.vfs.outlook import OutlookConfig, OutlookVFS
>
> config = OutlookConfig(access_token=os.environ["MS_GRAPH_MAIL_TOKEN"])
> ws = Workspace({"/outlook": OutlookVFS(config)}, mode=MountMode.READ)
> result = await ws.shell("ls /outlook")
> print(await result.stdout_str())
> await ws.close()
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { MountMode, OutlookVFS, Workspace } from '@struktoai/mirage-node'
>
> const ws = new Workspace(
>   {
>     '/outlook': new OutlookVFS({
>       accessToken: process.env.MS_GRAPH_MAIL_TOKEN!,
>     }),
>   },
>   { mode: MountMode.READ },
> )
> const result = await ws.shell('ls /outlook')
> console.log(result.stdoutText)
> await ws.close()
> ```

## Layout

```text theme={null}
/outlook/
  Inbox/
    Projects/
      2026-11-03/
        Kickoff_agenda__AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0A.outlook.json
    2026-11-16/
      Q3_close_numbers__AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0B.outlook.json
      Q3_close_numbers__AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0B/
        close.xlsx
  Sent Items/
  Archive/
```

* A mail folder is named by its display name; child folders nest inside it,
  beside its day folders.
* A message file is Microsoft Graph's message JSON, its body as plain text.
* The part after `__` is the message's immutable Graph id, which stays the
  same when the message moves folders.

## Sample runs

```bash theme={null}
$ ls /outlook
Archive
Inbox
Sent Items
```

```bash theme={null}
$ grep -rl 'close numbers' /outlook/Inbox
/outlook/Inbox/2026-11-16/Q3_close_numbers__AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0B.outlook.json
```

```bash theme={null}
$ jq -r '.from.emailAddress.address, .body.content' /outlook/Inbox/2026-11-16/Q3_close_numbers__AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0B.outlook.json
adele@contoso.com
Numbers attached, final by Friday.
```

The mount is read-only. Send, reply and forward with the
[`himalaya`](https://docs.mirage.strukto.ai/home/setup/cli/himalaya) CLI signed in with a token (see
[Email setup](https://docs.mirage.strukto.ai/home/setup/email.md)); the sent copy shows in `Sent Items`.

## SDK guides

> [card] [Python](https://docs.mirage.strukto.ai/python/vfs/outlook.md)
>
> Every config field, the layout and the VFS.md.

> [card] [TypeScript](https://docs.mirage.strukto.ai/typescript/vfs/outlook.md)
>
> Every config field, the layout and the VFS.md.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.