Skip to main content
Glama

get_email

Retrieve detailed email information, including body content and attachment metadata, using email ID and account ID. Manage content size with customizable limits for streamlined email data extraction on Microsoft MCP.

Instructions

Get email details with size limits

Args: email_id: The email ID account_id: The account ID include_body: Whether to include the email body (default: True) body_max_length: Maximum characters for body content (default: 50000) include_attachments: Whether to include attachment metadata (default: True)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
body_max_lengthNo
email_idYes
include_attachmentsNo
include_bodyNo

Implementation Reference

  • The handler function for the 'get_email' tool. It retrieves email details from Microsoft Graph API, supports optional body inclusion with truncation, and processes attachments by removing content bytes to limit size.
    @mcp.tool def get_email( email_id: str, account_id: str, include_body: bool = True, body_max_length: int = 50000, include_attachments: bool = True, ) -> dict[str, Any]: """Get email details with size limits Args: email_id: The email ID account_id: The account ID include_body: Whether to include the email body (default: True) body_max_length: Maximum characters for body content (default: 50000) include_attachments: Whether to include attachment metadata (default: True) """ params = {} if include_attachments: params["$expand"] = "attachments($select=id,name,size,contentType)" result = graph.request("GET", f"/me/messages/{email_id}", account_id, params=params) if not result: raise ValueError(f"Email with ID {email_id} not found") # Truncate body if needed if include_body and "body" in result and "content" in result["body"]: content = result["body"]["content"] if len(content) > body_max_length: result["body"]["content"] = ( content[:body_max_length] + f"\n\n[Content truncated - {len(content)} total characters]" ) result["body"]["truncated"] = True result["body"]["total_length"] = len(content) elif not include_body and "body" in result: del result["body"] # Remove attachment content bytes to reduce size if "attachments" in result and result["attachments"]: for attachment in result["attachments"]: if "contentBytes" in attachment: del attachment["contentBytes"] return result

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/elyxlz/microsoft-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server