Skip to content

Support multipart/alternative email sending#68

Merged
rockfordlhotka merged 7 commits into
mainfrom
copilot/support-multipart-alternative-email-sending
Jun 9, 2026
Merged

Support multipart/alternative email sending#68
rockfordlhotka merged 7 commits into
mainfrom
copilot/support-multipart-alternative-email-sending

Conversation

Copilot AI commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

The send_email tool only supported a single body + bodyFormat ("html" or "text"), which led to formatting failures when agents mismatched content and format (e.g., sending plain text with bodyFormat: "html").

Changes

  • New parameters: textBody and htmlBody on SendEmailTool.SendEmail
  • New bodyFormat value: "multipart" — requires both textBody and htmlBody; validates at the tool layer before reaching providers
  • Provider updates:
    • Google/IMAP: true multipart/alternative MIME via MimeKit BodyBuilder (sets both TextBody and HtmlBody)
    • M365/Outlook.com: uses htmlBody as the Graph API body (Graph constructs MIME internally; no native multipart/alternative support in the SDK)
  • Backward compatible: existing body + bodyFormat: "html"/"text" behavior unchanged
  • Tests: HTML-only, text-only, multipart success, and multipart validation error cases

Example usage

{
  "to": ["recipient@example.com"],
  "subject": "Hello",
  "bodyFormat": "multipart",
  "textBody": "Plain text fallback",
  "htmlBody": "<html><body><h1>Hello</h1><p>Rich content.</p></body></html>"
}

Documentation notes in tool descriptions

  • bodyFormat: "html" requires actual HTML markup
  • Markdown/plain text is not automatically converted to HTML
  • Use "multipart" when both readable fallback text and formatted HTML are needed

Copilot AI added 2 commits June 3, 2026 12:41
- Add textBody and htmlBody parameters to SendEmailTool
- Support bodyFormat "multipart" alongside existing "html" and "text"
- Update IProviderService interface with new optional parameters
- Update all provider implementations (M365, OutlookCom, Google, IMAP, ICS, JSON)
- Google and IMAP providers use MimeKit BodyBuilder for true multipart/alternative
- M365 and OutlookCom providers use HTML body (Graph API limitation)
- Add validation requiring both textBody and htmlBody when multipart is specified
- Add tests for HTML-only, text-only, and multipart sends
- All existing tests pass unchanged
Address review feedback: replace null-forgiving operator (!) with
null-coalescing operator (?? string.Empty) for safety in M365 and
OutlookCom providers.
Copilot AI changed the title [WIP] Add multipart/alternative email sending support Support multipart/alternative email sending Jun 3, 2026
Copilot AI requested a review from rockfordlhotka June 3, 2026 12:44
rockfordlhotka and others added 4 commits June 9, 2026 10:21
…Graph multipart

- Move textBody and htmlBody parameters before CancellationToken in
  IProviderService.SendEmailAsync and all implementations (CA1068).
- Add LogWarning in M365ProviderService and OutlookComProviderService when
  bodyFormat is 'multipart', since the Graph SDK cannot construct a true
  multipart/alternative message and silently drops the plain-text body.
- Update all call sites (SendEmailTool, UnsubscribeFromEmailTool) and all
  test mock setups/callbacks to match the new parameter order.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- docs/mcp-tools.md: document 'multipart' bodyFormat value and
  textBody/htmlBody parameters with M365/Outlook.com limitation note
- Skills/email.md: update send_email signature and parameter descriptions
- changelogs/2026-06-09-multipart-email.md: new changelog entry

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rockfordlhotka
rockfordlhotka marked this pull request as ready for review June 9, 2026 16:17
@rockfordlhotka
rockfordlhotka merged commit ab78887 into main Jun 9, 2026
1 check passed
@rockfordlhotka
rockfordlhotka deleted the copilot/support-multipart-alternative-email-sending branch June 9, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multipart/alternative email sending

2 participants