Skip to main content
Glama

search_sent_emails

Find sent emails in Outlook using search keywords to retrieve specific messages from your sent items folder.

Instructions

Search sent emails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch keywords
countNoNumber of results to return

Implementation Reference

  • Core handler function for search_sent_emails tool. Fetches a batch of recent sent emails, applies semantic search using EmailSummarizer, and returns top matching results.
    async searchSentEmails(query: string, count: number = 10): Promise<EmailMessage[]> { const emails = await this.getSentEmails(Math.min(count * 2, 50)); const { EmailSummarizer } = await import('./email-summarizer.js'); const searchResults = EmailSummarizer.searchEmails(emails, query); return searchResults.slice(0, count); }
  • Key helper method implementing case-insensitive full-text search across email subject, sender, and body (stripping HTML).
    static searchEmails(emails: EmailMessage[], searchTerm: string): EmailMessage[] { if (!searchTerm.trim()) { return emails; } const normalizedSearchTerm = searchTerm.toLowerCase(); return emails.filter(email => { // Search in subject const subjectMatch = email.subject.toLowerCase().includes(normalizedSearchTerm); // Search in sender const senderMatch = email.sender.toLowerCase().includes(normalizedSearchTerm); // Search in body content (remove HTML tags before searching) const cleanBody = email.body.replace(/<[^>]*>/g, '').toLowerCase(); const bodyMatch = cleanBody.includes(normalizedSearchTerm); return subjectMatch || senderMatch || bodyMatch; }); }
  • src/index.ts:587-605 (registration)
    MCP server dispatch handler for search_sent_emails tool calls, validating inputs and formatting response.
    case 'search_sent_emails': { const query = (args as any)?.query; const count = (args as any)?.count || 10; if (!query) { throw new Error('Search query is required'); } const emails = await outlookManager.searchSentEmails(query, count); return { content: [ { type: 'text', text: `šŸ” **Search Results: "${query}"**\nTotal: ${emails.length} items\nUnread: ${emails.filter(e => !e.isRead).length} items\n\nšŸ“‹ **Search Results List:**\n` + emails.map((email, index) => `${index + 1}. ${email.isRead ? 'āœ…' : 'šŸ“©'} **${email.subject}**\n From: ${email.sender}\n Time: ${email.receivedTime}\n EntryID: ${email.id}\n StoreID: ${email.storeId || 'N/A'}\n Search Context: ${email.body?.includes(query) ? 'Match in content' : 'Match in subject'}: ${email.subject}\n Preview: ${email.body?.substring(0, 100)}...\n` ).join('\n') }, ], }; }
  • Tool registration including name, description, and input schema (query: string required, count: number optional default 10).
    { name: "search_sent_emails", description: "Search sent emails", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search keywords" }, count: { type: "number", description: "Number of results to return", default: 10 } }, required: ["query"] } },
  • Helper method to retrieve recent sent emails from Outlook Sent Items folder using PowerShell automation.
    async getSentEmails(count: number = 10): Promise<EmailMessage[]> { return this.getEmailsFromFolder(5, count, "[SentOn]"); // 5 = Sent 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/cqyefeng119/windows-outlook-mcp'

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