# Modify Email — Microsoft Outlook Email

> Apply one or more state mutations to an email message: mark read/unread, add/remove categories, move to a folder, or change the flag status. All params except messageId are optional — only the ones you provide are applied. Use Find Email…

- Key: `microsoft_outlook-modify-email`
- Type: Action (Write)
- Version: 0.0.6
- App: Microsoft Outlook Email (`microsoft_outlook`) — https://pipedream.com/apps/microsoft-outlook.md
- This page (HTML): https://pipedream.com/apps/microsoft-outlook/actions/modify-email
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/microsoft_outlook/actions/modify-email/modify-email.mjs

## Description

Apply one or more state mutations to an email message: mark read/unread, add/remove categories, move to a folder, or change the flag status. All params except `messageId` are optional — only the ones you provide are applied. Use **Find Email** to obtain a message `id` before modifying. Recipes: Mark read: `isRead: true` | Mark unread: `isRead: false` Add category: `addCategories: ["Follow Up"]` | Remove category: `removeCategories: ["Follow Up"]` Move to archive: `destinationFolderId: "archive"` | Move to inbox: `destinationFolderId: "inbox"` Flag: `flagStatus: "flagged"` | Unflag: `flagStatus: "notFlagged"` | Mark complete: `flagStatus: "complete"` Example: `modify-email(messageId="AAMk...", isRead=true)` → marks the message as read. Example: `modify-email(messageId="AAMk...", addCategories=["Eval-Seinfeld"], destinationFolderId="archive")` → adds a category AND moves to archive in a single call. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `messageId` | `string` | Yes | The Microsoft Graph message ID. Obtain from Find Email (id field in results). |
| `isRead` | `boolean` | No | true marks the message as read; false marks it as unread. Omit to leave unchanged. |
| `addCategories` | `string[]` | No | Category names to add to the message, e.g. ["Follow Up", "Important"]. Existing categories are preserved. |
| `removeCategories` | `string[]` | No | Category names to remove from the message. Existing categories not listed here are preserved. |
| `destinationFolderId` | `string` | No | Move the message to this folder. Use well-known names (inbox, archive, deleteditems, drafts, junkemail, sentitems) or a folder ID. Omit to leave in current folder. |
| `flagStatus` | `string` | No | Set the message flag: flagged (flag it), notFlagged (remove flag), or complete (mark flag as done). |
| `userId` | `string` | No | The user ID or UPN of a shared mailbox. Omit to use the authenticated user's mailbox. |

## 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-modify-email",
  arguments: {
    messageId: "Message ID",
    isRead: true,
  },
})
```

**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-modify-email",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    microsoft_outlook: { authProvisionId: "apn_xxxxxxx" },
    messageId: "Message ID",
    isRead: true,
  },
})

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-modify-email",
    "configured_props": {
      "microsoft_outlook": { "authProvisionId": "apn_xxxxxxx" },
      "messageId": "Message ID",
      "isRead": true
    }
  }'
```

---

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