send_email
Send emails with customizable recipients, subject, and body. Supports CC, BCC, and HTML content, integrated with Google Calendar without deletion capabilities.
Instructions
Send a new email
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bcc | No | BCC recipients (comma-separated) | |
| body | Yes | Email body (can include HTML) | |
| cc | No | CC recipients (comma-separated) | |
| subject | Yes | Email subject | |
| to | Yes | Recipient email address |
Implementation Reference
- src/index.ts:361-411 (handler)The handler function that executes the send_email tool: destructures args, builds raw MIME email, base64url encodes it, sends via Gmail API, returns success/error response.private async handleSendEmail(args: any) { try { const { to, subject, body, cc, bcc } = args; // Create email content const message = [ 'Content-Type: text/html; charset=utf-8', 'MIME-Version: 1.0', `To: ${to}`, cc ? `Cc: ${cc}` : '', bcc ? `Bcc: ${bcc}` : '', `Subject: ${subject}`, '', body, ].filter(Boolean).join('\r\n'); // Encode the email const encodedMessage = Buffer.from(message) .toString('base64') .replace(/\+/g, '-') .replace(/\//g, '_') .replace(/=+$/, ''); // Send the email const response = await this.gmail.users.messages.send({ userId: 'me', requestBody: { raw: encodedMessage, }, }); return { content: [ { type: 'text', text: `Email sent successfully. Message ID: ${response.data.id}`, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error sending email: ${error.message}`, }, ], isError: true, }; } }
- src/index.ts:101-126 (schema)Input schema defining parameters for send_email tool: to, subject, body (required), cc, bcc.inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient email address', }, subject: { type: 'string', description: 'Email subject', }, body: { type: 'string', description: 'Email body (can include HTML)', }, cc: { type: 'string', description: 'CC recipients (comma-separated)', }, bcc: { type: 'string', description: 'BCC recipients (comma-separated)', }, }, required: ['to', 'subject', 'body'] },
- src/index.ts:98-127 (registration)Registration of send_email tool in the tools list, including name, description, and inputSchema.{ name: 'send_email', description: 'Send a new email', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient email address', }, subject: { type: 'string', description: 'Email subject', }, body: { type: 'string', description: 'Email body (can include HTML)', }, cc: { type: 'string', description: 'CC recipients (comma-separated)', }, bcc: { type: 'string', description: 'BCC recipients (comma-separated)', }, }, required: ['to', 'subject', 'body'] }, },
- src/index.ts:234-235 (registration)Switch case in CallToolRequestSchema handler that routes send_email calls to the handleSendEmail function.case 'send_email': return await this.handleSendEmail(request.params.arguments);