draft_gmail_message
Create Gmail drafts with attachments, CC/BCC, and send-as aliases. Draft new emails or replies within existing threads.
Instructions
Creates a draft email in the user's Gmail account. Supports both new drafts and reply drafts with optional attachments. Supports Gmail's "Send As" feature to draft from configured alias addresses.
Args: user_google_email (str): The user's Google email address. Required for authentication. subject (str): Email subject. body (str): Email body (plain text). body_format (Literal['plain', 'html']): Email body format. Defaults to 'plain'. to (Optional[str]): Optional recipient email address. Can be left empty for drafts. cc (Optional[str]): Optional CC email address. bcc (Optional[str]): Optional BCC email address. from_name (Optional[str]): Optional sender display name. If provided, the From header will be formatted as 'Name '. from_email (Optional[str]): Optional 'Send As' alias email address. The alias must be configured in Gmail settings (Settings > Accounts > Send mail as). If not provided, the draft will be from the authenticated user's primary email address. thread_id (Optional[str]): Optional Gmail thread ID to reply within. When provided, creates a reply draft. in_reply_to (Optional[str]): Optional RFC Message-ID of the message being replied to (e.g., 'message123@gmail.com'). references (Optional[str]): Optional chain of RFC Message-IDs for proper threading (e.g., 'msg1@gmail.com msg2@gmail.com'). attachments (List[Dict[str, str]]): Optional list of attachments. Each dict can contain: Option 1 - File path (auto-encodes): - 'path' (required): File path to attach - 'filename' (optional): Override filename - 'mime_type' (optional): Override MIME type (auto-detected if not provided) Option 2 - Base64 content: - 'content' (required): Standard base64-encoded file content (not urlsafe) - 'filename' (required): Name of the file - 'mime_type' (optional): MIME type (defaults to 'application/octet-stream') include_signature (bool): Whether to append Gmail signature HTML from send-as settings. If unavailable (e.g., missing gmail.settings.basic scope), the draft is still created without signature. quote_original (bool): Whether to include the original message as a quoted reply. Requires thread_id to be provided. When enabled, fetches the original message and appends it below the signature. Defaults to False.
Returns: str: Confirmation message with the created draft's ID.
Examples: # Create a new draft draft_gmail_message(subject="Hello", body="Hi there!", to="user@example.com")
# Create a draft from a configured alias (Send As)
draft_gmail_message(
subject="Business Inquiry",
body="Hello from my business address...",
to="user@example.com",
from_email="business@mydomain.com"
)
# Create a plaintext draft with CC and BCC
draft_gmail_message(
subject="Project Update",
body="Here's the latest update...",
to="user@example.com",
cc="manager@example.com",
bcc="archive@example.com"
)
# Create a HTML draft with CC and BCC
draft_gmail_message(
subject="Project Update",
body="<strong>Hi there!</strong>",
body_format="html",
to="user@example.com",
cc="manager@example.com",
bcc="archive@example.com"
)
# Create a reply draft in plaintext
draft_gmail_message(
subject="Re: Meeting tomorrow",
body="Thanks for the update!",
to="user@example.com",
thread_id="thread_123",
in_reply_to="<message123@gmail.com>",
references="<original@gmail.com> <message123@gmail.com>"
)
# Create a reply draft in HTML
draft_gmail_message(
subject="Re: Meeting tomorrow",
body="<strong>Thanks for the update!</strong>",
body_format="html",
to="user@example.com",
thread_id="thread_123",
in_reply_to="<message123@gmail.com>",
references="<original@gmail.com> <message123@gmail.com>"
)Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cc | No | Optional CC email address. | |
| to | No | Optional recipient email address. | |
| bcc | No | Optional BCC email address. | |
| body | Yes | Email body (plain text). | |
| subject | Yes | Email subject. | |
| from_name | No | Optional sender display name (e.g., 'Peter Hartree'). If provided, the From header will be formatted as 'Name <email>'. | |
| thread_id | No | Optional Gmail thread ID to reply within. | |
| from_email | No | Optional 'Send As' alias email address. Must be configured in Gmail settings (Settings > Accounts > Send mail as). If not provided, uses the authenticated user's email. | |
| references | No | Optional chain of Message-IDs for proper threading. | |
| attachments | No | Optional list of attachments. Each can have: 'path' (file path, auto-encodes), OR 'content' (standard base64, not urlsafe) + 'filename'. Optional 'mime_type' (auto-detected from path if not provided). | |
| body_format | No | Email body format. Use 'plain' for plaintext or 'html' for HTML content. | plain |
| in_reply_to | No | Optional RFC Message-ID of the message being replied to (e.g., '<message123@gmail.com>'). | |
| quote_original | No | Whether to include the original message as a quoted reply. Requires thread_id. Defaults to false. | |
| include_signature | No | Whether to append the Gmail signature from Settings > Signature when available. Defaults to true. | |
| user_google_email | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |