Skip to content

feat(gmail): add replyToMessage, forwardMessage, and complete human-parity email operations #43

@AojdevStudio

Description

@AojdevStudio

Summary

The Gmail service should support all standard email operations a human would perform. Currently missing: direct reply (threaded), forward, reply-all, add/download attachments, and trash/delete.

Problem

Right now sendMessage and createDraft accept inReplyTo but threading is unreliable (especially with mailing list / ConvertKit emails). There's no explicit reply operation that guarantees correct threading with In-Reply-To + References headers. Forwarding is completely absent.

Proposed Operations

Priority 1 — Core

Operation Purpose Gmail API
replyToMessage Reply to a specific message (auto-sets subject, threading headers, recipient) users.messages.send with proper In-Reply-To, References, threadId
replyAllToMessage Reply-all (includes CC recipients from original) Same as above, auto-populates all recipients
forwardMessage Forward a message to new recipients with original content quoted users.messages.send with forwarded body + attachments

Priority 2 — Attachment Handling

Operation Purpose Gmail API
listAttachments List attachments on a message (name, size, mimeType) users.messages.attachments.get
downloadAttachment Download an attachment by ID users.messages.attachments.get
sendWithAttachments Send/draft with file attachments Multipart MIME message

Priority 3 — Message Management

Operation Purpose Gmail API
trashMessage Move message to trash users.messages.trash
untrashMessage Restore from trash users.messages.untrash
deleteMessage Permanently delete (skip trash) users.messages.delete
markAsRead Remove UNREAD label users.messages.modify (already possible via modifyLabels but a convenience alias)
archiveMessage Remove INBOX label users.messages.modify (same — convenience alias)

Threading Fix for replyToMessage

The key issue with current inReplyTo is that we pass the Gmail message ID instead of building proper MIME headers. A correct reply needs:

  1. Set threadId to the original message's threadId
  2. Set In-Reply-To header to the original message's Message-ID header value
  3. Set References header to original's References + Message-ID
  4. Prefix subject with Re: if not already present
  5. Auto-populate To from the original sender

replyToMessage should handle all of this from just a messageId input.

Human-Parity Checklist

After this + #42 (draft management), Gmail operations should cover:

  • Read messages (getMessage, searchMessages, listMessages)
  • Read threads (getThread, listThreads)
  • Send new email (sendMessage)
  • Create draft (createDraft)
  • Send draft (sendDraft)
  • Label management (modifyLabels, listLabels)
  • Reply to email ← this issue
  • Reply-all ← this issue
  • Forward email ← this issue
  • List/get/update/delete draftsfeat(gmail): add listDrafts, getDraft, updateDraft, and deleteDraft operations #42
  • Attachments (list/download/send) ← this issue
  • Trash/delete messages ← this issue

Acceptance Criteria

  • replyToMessage({ messageId, body }) sends a correctly threaded reply
  • replyAllToMessage({ messageId, body }) includes all original recipients
  • forwardMessage({ messageId, to, body? }) forwards with quoted original
  • Threading works reliably with mailing lists and marketing platforms (ConvertKit, Kit, etc.)
  • Attachment operations functional for common file types
  • Trash/delete operations with appropriate safety checks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions