View as Markdown
Gmail icon

Gmail ACTION

Get Attachment Content

Return a Gmail attachment's content as base64 so a client can use it directly, for example to show an image inline or read a small text file. Call Find Emails with fields: ["subject", "attachments"], or Get Thread, first to get the message id and the attachment's partId. Not for saving a file to disk (use Download Attachment) or for listing a message's attachments (use Find Emails or Get Thread). data is standard padded base64 (+ and /, not base64url), so it can go straight into data:<mimeType>;base64,<data>. size is the decoded byte length. Attachments larger than maxBytes are not downloaded: the result has tooLarge: true, the real size, a message, and data: null; the default limit is 2000000 bytes and it can be raised to at most 5000000. Returns filename, mimeType, size, encoding (always base64) and data. Example: messageId="19a2b3c4d5e6f789", partId="1" → { filename: "chart.png", mimeType: "image/png", size: 1843, encoding: "base64", data: "iVBORw0KGgo..." }. See the documentation.
  • Action
  • Read only
  • OAuth
  • SDK
  • MCP

IMPLEMENTATION

Call this tool

Connect a user's Gmail account once, then configure and run Get Attachment Content from your backend or agent.

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-get-attachment-content",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    gmail: { authProvisionId: "apn_xxxxxxx" },
    messageId: "Message ID",
    partId: "Part ID",
  },
})

console.log(result)

SCHEMA

Inputs

Pipedream supplies the connected account. Your application provides the operation-specific values below. Dynamic inputs are resolved against that user's account.

Get Attachment Content inputs
Property Type Description
messageId Message ID string
The id of the message containing the attachment, e.g. 19a2b3c4d5e6f789. Obtain this from Find Emails or Get Thread.
Required
partId Part ID string
The attachment's partId from the message's attachments list, e.g. 1 or 0.2. Get it from Find Emails with fields: ["subject", "attachments"], or from Get Thread.
Required
maxBytes Max Bytes integer
Largest attachment to return, in bytes, e.g. 2000000. Larger attachments are rejected before download. Defaults to 2000000; the maximum allowed is 5000000.
Optional

REFERENCE

Tool details

Behavior hints are published with the component in the Pipedream registry and surface as MCP tool annotations, so an agent can reason about a tool before it calls it.

Registry key
gmail-get-attachment-content
Version
0.0.1
App
Gmail
Authentication
OAuth
Read-only
Yes
Destructive
No
Open world
Yes