Skip to main content
Glama

mcp-google-sheets

download-email-attachment.ts1.38 kB
import { createAction, Property } from '@activepieces/pieces-framework'; import { Client, PageCollection } from '@microsoft/microsoft-graph-client'; import { FileAttachment } from '@microsoft/microsoft-graph-types'; import { microsoftOutlookAuth } from '../common/auth'; export const downloadAttachmentAction = createAction({ auth: microsoftOutlookAuth, name: 'downloadAttachment', displayName: 'Download Attachment', description: 'Download attachments from a specific email message.', props: { messageId: Property.ShortText({ displayName: 'Message ID', description: 'The ID of the email message containing the attachment.', required: true, }), }, async run(context) { const { messageId } = context.propsValue; const client = Client.initWithMiddleware({ authProvider: { getAccessToken: () => Promise.resolve(context.auth.access_token), }, }); const response: PageCollection = await client .api(`/me/messages/${messageId}/attachments`) .get(); const attachments = []; for (const attachment of response.value as FileAttachment[]) { if (attachment.name && attachment.contentBytes) { attachments.push({ ...attachment, file: await context.files.write({ fileName: attachment.name || 'test.png', data: Buffer.from(attachment.contentBytes, 'base64'), }), }); } } return attachments; }, });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/activepieces/activepieces'

If you have feedback or need assistance with the MCP directory API, please join our Discord server