# List Folders — Microsoft Outlook Email

> Retrieves mail folders for the authenticated user. Returns { count, folders } where folders contains each folder's id, displayName, parentFolderId, childFolderCount, totalItemCount, and unreadItemCount. The count field reflects the true…

- Key: `microsoft_outlook-list-folders`
- Type: Action (Read-only)
- Version: 1.0.2
- App: Microsoft Outlook Email (`microsoft_outlook`) — https://pipedream.com/apps/microsoft-outlook.md
- This page (HTML): https://pipedream.com/apps/microsoft-outlook/actions/list-folders
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/microsoft_outlook/actions/list-folders/list-folders.mjs

## Description

Retrieves mail folders for the authenticated user. Returns `{ count, folders }` where `folders` contains each folder's `id`, `displayName`, `parentFolderId`, `childFolderCount`, `totalItemCount`, and `unreadItemCount`. The `count` field reflects the true API total when Microsoft Graph returns `@odata.count` (supported for top-level mailFolders queries); when `Include Subfolders` is `true` or Graph does not return `@odata.count` for the requested filter, `count` equals the number of folders actually retrieved. **Use this action to resolve a folder display name to its ID** — set `Display Name` to filter by exact name. Use **Get Folder** instead when you already have the folder ID. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders?view=graph-rest-1.0&tabs=http)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `displayName` | `string` | No | Filter to folders whose display name exactly matches this value. Use this to resolve a known folder name to its ID. Applied server-side when Include Subfolders is false; applied client-side when true. |
| `maxResults` | `integer` | No | Maximum number of folders to return (default: 100). Min 1, max 1000. For name-based lookups when the total folder count is unknown, raise this value or set Include Subfolders to true. Graph API maximum is 999 per page. |
| `includeSubfolders` | `boolean` | No | If true, recursively includes all subfolders at every nesting level. Set to true when searching for a folder by display name if you don't know whether it is a top-level folder. Default is false, which returns only top-level folders. Note: count falls back to the number of folders retrieved in this mode. |
| `includeHiddenFolders` | `boolean` | No | If true, includes hidden system folders (e.g. AllItems, RecoverableItemsDeletions, SearchFolders, Clutter). Set to true only when specifically looking for a system or hidden folder. Default is false. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "microsoft_outlook",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "microsoft_outlook-list-folders",
  arguments: {
    displayName: "Display Name",
    maxResults: 10,
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "microsoft_outlook-list-folders",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    microsoft_outlook: { authProvisionId: "apn_xxxxxxx" },
    displayName: "Display Name",
    maxResults: 10,
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "microsoft_outlook-list-folders",
    "configured_props": {
      "microsoft_outlook": { "authProvisionId": "apn_xxxxxxx" },
      "displayName": "Display Name",
      "maxResults": 10
    }
  }'
```

---

- App: https://pipedream.com/apps/microsoft-outlook.md · All apps: https://pipedream.com/apps
