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
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes | ||
| destination_folder | Yes | ||
| email_id | Yes |
Implementation Reference
- src/microsoft_mcp/tools.py:423-453 (handler)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"]}
- src/microsoft_mcp/tools.py:10-20 (helper)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() }