Skip to main content
Glama

move_email

Transfer emails to specified folders using the Microsoft MCP server. Define email ID, destination folder, and account ID to organize Outlook emails efficiently.

Instructions

Move email to another folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
destination_folderYes
email_idYes

Implementation Reference

  • Implements the move_email tool by resolving the destination folder ID from mail folders and using Microsoft Graph API to move the specified email.
    def move_email( email_id: str, destination_folder: str, account_id: str ) -> dict[str, Any]: """Move email to another folder""" folder_path = FOLDERS.get(destination_folder.casefold(), destination_folder) folders = graph.request("GET", "/me/mailFolders", account_id) folder_id = None if not folders: raise ValueError("Failed to retrieve mail folders") if "value" not in folders: raise ValueError(f"Unexpected folder response structure: {folders}") for folder in folders["value"]: if folder["displayName"].lower() == folder_path.lower(): folder_id = folder["id"] break if not folder_id: raise ValueError(f"Folder '{destination_folder}' not found") payload = {"destinationId": folder_id} result = graph.request( "POST", f"/me/messages/{email_id}/move", account_id, json=payload ) if not result: raise ValueError("Failed to move email - no response from server") if "id" not in result: raise ValueError(f"Failed to move email - unexpected response: {result}") return {"status": "moved", "new_id": result["id"]}
  • Mapping of common folder names to Microsoft Graph folder paths, used in move_email to resolve destination_folder.
    FOLDERS = { k.casefold(): v for k, v in { "inbox": "inbox", "sent": "sentitems", "drafts": "drafts", "deleted": "deleteditems", "junk": "junkemail", "archive": "archive", }.items() }

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