# Send Email — Gmail

> Send a new email OR reply to an existing thread from the authenticated Gmail account. For a fresh message, set to/subject/body; leave inReplyToMessageId blank. To reply to a thread, pass the id of any message in that thread as…

- Key: `gmail-send-email`
- Type: Action (Write)
- Version: 0.3.3
- App: Gmail (`gmail`) — https://pipedream.com/apps/gmail.md
- This page (HTML): https://pipedream.com/apps/gmail/actions/send-email
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/gmail/actions/send-email/send-email.mjs

## Description

Send a new email OR reply to an existing thread from the authenticated Gmail account. For a fresh message, set `to`/`subject`/`body`; leave `inReplyToMessageId` blank. To reply to a thread, pass the `id` of any message in that thread as `inReplyToMessageId` — the tool preserves threading (`References`, `In-Reply-To`, `threadId`) and auto-prefixes `Re:` on the subject. Use **Find Emails** or **Get Thread** to locate the message ID. Set `replyAll: true` to fan-out to the original `From`/`To`/`Cc` (minus the user's own address); otherwise only the original sender is addressed. `bodyType` controls whether `body` is treated as plain text (default) or HTML. To send to yourself, pass `"me"` in `to` — the action resolves it to the authenticated user's email address. No pre-call to **Get Current User** required. Attachments: for small inline content (the common case in MCP / cloud runs), set `attachmentContent` to the file's text contents and `attachmentFilename` to its name. For files already on disk (Pipedream workflows, File Stash), use `attachments[]` + `attachmentFilenames[]` instead. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `to` | `string[]` | No | Recipient email addresses. Pass "me" to send to yourself — the action resolves it to the authenticated user's email address. Ignored when replyAll is true (recipients are computed from the original message). |
| `cc` | `string[]` | No | Cc recipient email addresses. Pass "me" to include yourself. |
| `bcc` | `string[]` | No | Bcc recipient email addresses. Pass "me" to include yourself. |
| `subject` | `string` | No | Subject line. When inReplyToMessageId is set, the subject is taken from the replied-to message with Re: prefixed and this value is ignored. |
| `body` | `string` | Yes | Include an email body as either plain text or HTML. If HTML, make sure to set the "Body Type" prop to html. |
| `bodyType` | `string` | No | Choose to send as plain text or HTML. Defaults to plaintext. |
| `fromName` | `string` | No | Specify the name that will be displayed in the "From" section of the email. |
| `fromEmail` | `string` | No | Specify the email address that will be displayed in the "From" section of the email. Options are loaded from the connected account. |
| `replyTo` | `string` | No | Specify the email address that will appear on the "Reply-To" field, if different than the sender's email. |
| `inReplyToMessageId` | `string` | No | To send this email as a reply, pass the id of any message in the target thread (from Find Emails or Get Thread). The action will preserve References/In-Reply-To headers, thread correctly, and auto-prefix Re: on the subject. |
| `replyAll` | `boolean` | No | When inReplyToMessageId is set, fan-out recipients to the original From/To/Cc (minus the user's own address). Ignored when inReplyToMessageId is blank. |
| `attachmentContent` | `string` | No | Inline text content to attach as a file. Use this instead of a file path when running in an MCP / cloud environment where there is no local filesystem to read from. |
| `attachmentFilename` | `string` | No | Filename for the inline attachment (include extension, e.g. dna.txt). Used only when attachmentContent is provided. Defaults to attachment.txt. |
| `attachmentFilenames` | `string[]` | No | Filenames for each attached file (include the extension, e.g. report.pdf, dna.txt). Must be the same length as attachments — index i in this list pairs with index i in attachments. |
| `attachments` | `string[]` | No | Paths to files on disk (or public URLs). Each entry pairs with the same-index entry in attachmentFilenames[]. If running in MCP or a cloud environment without a local filesystem, use attachmentContent instead. |
| `syncDir` | `dir` | No | SyncDir |

## 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": "gmail",
      },
    },
  },
)

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: "gmail-send-email",
  arguments: {
    to: ["To"],
    cc: ["Cc"],
  },
})
```

**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: "gmail-send-email",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    gmail: { authProvisionId: "apn_xxxxxxx" },
    to: ["To"],
    cc: ["Cc"],
  },
})

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": "gmail-send-email",
    "configured_props": {
      "gmail": { "authProvisionId": "apn_xxxxxxx" },
      "to": ["To"],
      "cc": ["Cc"]
    }
  }'
```

---

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