create_draft
Generate and save new email drafts in Microsoft Outlook with recipients, subject, body, CC, and BCC fields. Simplify email creation via direct integration with the Outlook MCP Server.
Instructions
Create new email draft
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bcc | No | BCC email addresses | |
| body | Yes | Email content | |
| cc | No | CC email addresses | |
| subject | Yes | Email subject | |
| to | Yes | Recipient email addresses |
Implementation Reference
- src/outlook-manager.ts:327-361 (handler)Core handler function that executes PowerShell script to create a new email draft in Outlook using the Outlook COM interop.async createDraft(draft: EmailDraft): Promise<string> { const cleanSubject = this.cleanText(draft.subject); // Don't clean the body for drafts - preserve line breaks const formattedBody = this.formatBodyForOutlook(draft.body); const script = ` try { Add-Type -AssemblyName "Microsoft.Office.Interop.Outlook" $outlook = New-Object -ComObject Outlook.Application $mail = $outlook.CreateItem(0) $mail.Subject = "${cleanSubject.replace(/"/g, '""')}" $mail.Body = "${formattedBody.replace(/"/g, '""')}" foreach ($recipient in @("${draft.to.join('","')}")) { if ($recipient.Trim()) { $mail.Recipients.Add($recipient.Trim()) | Out-Null } } $mail.Recipients.ResolveAll() | Out-Null $mail.Save() Write-Output "success" } catch { Write-Output "error: $($_.Exception.Message)" } `; const result = await this.executePowerShell(script); if (result.startsWith('error:')) { throw new Error(result.substring(7)); } return 'Draft created successfully'; }
- src/index.ts:85-117 (registration)Tool registration in the MCP server's listTools handler, including name, description, and input schema.{ name: "create_draft", description: "Create new email draft", inputSchema: { type: "object", properties: { to: { type: "array", items: { type: "string" }, description: "Recipient email addresses" }, subject: { type: "string", description: "Email subject" }, body: { type: "string", description: "Email content" }, cc: { type: "array", items: { type: "string" }, description: "CC email addresses" }, bcc: { type: "array", items: { type: "string" }, description: "BCC email addresses" } }, required: ["to", "subject", "body"] } },
- src/index.ts:532-549 (handler)MCP server dispatch handler for 'create_draft' tool call, which constructs EmailDraft and delegates to OutlookManager.createDraft.case 'create_draft': { const draft: EmailDraft = { to: (args as any)?.to || [], subject: (args as any)?.subject || '', body: (args as any)?.body || '', cc: (args as any)?.cc, bcc: (args as any)?.bcc, }; const result = await outlookManager.createDraft(draft); return { content: [ { type: 'text', text: `✅ **Email Draft Created Successfully**\n\n**Subject:** ${draft.subject}\n**To:** ${draft.to.join(', ')}\n${draft.cc ? `**CC:** ${draft.cc.join(', ')}\n` : ''}**Result:** ${result}`, }, ], }; }
- src/outlook-manager.ts:15-22 (schema)TypeScript interface defining the EmailDraft type used by createDraft handler, matching the tool input schema.export interface EmailDraft { to: string[]; cc?: string[]; bcc?: string[]; subject: string; body: string; isHtml?: boolean; }