search_sent_emails
Search and retrieve sent emails in Microsoft Outlook using keywords and specify the number of results to return. Simplify email management with direct query capabilities.
Instructions
Search sent emails
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of results to return | |
| query | Yes | Search keywords |
Implementation Reference
- src/outlook-manager.ts:374-379 (handler)Core implementation of the search_sent_emails tool. Fetches a batch of recent sent emails via getSentEmails, uses EmailSummarizer helper to filter by query, and returns the 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); }
- src/index.ts:152-168 (schema)MCP tool schema definition specifying the input parameters: required 'query' string and optional 'count' number (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"] }
- src/index.ts:27-457 (registration)Tool registration in the MCP server's listTools handler, where search_sent_emails is listed among available tools with its schema.return { tools: [ { name: "get_inbox_emails", description: "Get inbox email list", inputSchema: { type: "object", properties: { count: { type: "number", description: "Number of emails to retrieve", default: 10 } } } }, { name: "get_email_by_id", description: "Get specific email by ID", inputSchema: { type: "object", properties: { id: { type: "string", description: "Email ID" } }, required: ["id"] } }, { name: "summarize_email", description: "Summarize individual email content", inputSchema: { type: "object", properties: { email_id: { type: "string", description: "Email ID to summarize" } }, required: ["email_id"] } }, { name: "summarize_inbox", description: "Summarize inbox emails", inputSchema: { type: "object", properties: { count: { type: "number", description: "Number of emails to summarize", default: 10 } } } }, { name: "create_draft", description: "Create new email draft", inputSchema: { type: "object", properties: { to: { type: "array", items: { type: "string" }, description: "Recipient email addresses" }, subject: { type: "string", description: "Email subject" }, body: { type: "string", description: "Email content" }, cc: { type: "array", items: { type: "string" }, description: "CC email addresses" }, bcc: { type: "array", items: { type: "string" }, description: "BCC email addresses" } }, required: ["to", "subject", "body"] } }, { name: "mark_email_as_read", description: "Mark email as read", inputSchema: { type: "object", properties: { email_id: { type: "string", description: "Email ID" } }, required: ["email_id"] } }, { name: "search_inbox_emails", description: "Search inbox emails", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search keywords" }, count: { type: "number", description: "Number of results to return", default: 10 } }, required: ["query"] } }, { 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"] } }, { name: "get_sent_emails", description: "Get sent emails list", inputSchema: { type: "object", properties: { count: { type: "number", description: "Number of sent emails to retrieve", default: 10 } } } }, { name: "get_draft_emails", description: "Get draft emails list", inputSchema: { type: "object", properties: { count: { type: "number", description: "Number of draft emails to retrieve", default: 10 } } } }, { name: "search_draft_emails", description: "Search draft emails", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search keywords" }, count: { type: "number", description: "Number of results to return", default: 10 } }, required: ["query"] } }, { name: "duplicate_email_as_draft", description: "Duplicate existing email as draft (preserving complete format)", inputSchema: { type: "object", properties: { source_email_id: { type: "string", description: "Original email ID to duplicate" }, store_id: { type: "string", description: "Store ID for the original email (optional but recommended)" }, new_subject: { type: "string", description: "New email subject (optional)" }, new_recipients: { type: "array", items: { type: "string" }, description: "New recipient list (optional)" } }, required: ["source_email_id"] } }, { name: "set_show_as", description: "Set Show As (Free/Busy status) for a calendar event", inputSchema: { type: "object", properties: { eventId: { type: "string", description: "Event ID to update" }, subject: { type: "string", description: "Subject of the event to find" }, startDate: { type: "string", description: "Start date of the event to find (ISO 8601 format)" }, showAs: { type: "string", enum: ["Free", "Tentative", "Busy", "OutOfOffice", "WorkingElsewhere"], description: "Show As status to set" } }, required: ["showAs"] } }, { name: "create_event_with_show_as", description: "Create a calendar event with specific Show As status (e.g., OutOfOffice for vacation)", inputSchema: { type: "object", properties: { subject: { type: "string", description: "Event subject/title" }, start: { type: "string", description: "Start date and time (ISO 8601 format)" }, end: { type: "string", description: "End date and time (ISO 8601 format)" }, location: { type: "string", description: "Event location" }, body: { type: "string", description: "Event description/body" }, showAs: { type: "string", enum: ["Free", "Tentative", "Busy", "OutOfOffice", "WorkingElsewhere"], description: "Show As status (default: Busy)" }, reminderMinutes: { type: "number", description: "Reminder time in minutes before the event" } }, required: ["subject", "start", "end"] } }, { name: "list_events", description: "List calendar events within a specified date range", inputSchema: { type: "object", properties: { startDate: { type: "string", description: "Start date (ISO 8601 format)" }, endDate: { type: "string", description: "End date (ISO 8601 format, optional)" }, calendar: { type: "string", description: "Calendar name (optional)" } }, required: ["startDate"] } }, { name: "update_event", description: "Update an existing calendar event", inputSchema: { type: "object", properties: { eventId: { type: "string", description: "Event ID to update" }, subject: { type: "string", description: "New event subject/title (optional)" }, startDate: { type: "string", description: "New start date in MM/DD/YYYY format (optional)" }, startTime: { type: "string", description: "New start time in HH:MM AM/PM format (optional)" }, endDate: { type: "string", description: "New end date in MM/DD/YYYY format (optional)" }, endTime: { type: "string", description: "New end time in HH:MM AM/PM format (optional)" }, location: { type: "string", description: "New event location (optional)" }, body: { type: "string", description: "New event description/body (optional)" }, calendar: { type: "string", description: "Calendar name (optional)" } }, required: ["eventId"] } }, { name: "delete_event", description: "Delete a calendar event by its ID", inputSchema: { type: "object", properties: { eventId: { type: "string", description: "Event ID to delete" }, calendar: { type: "string", description: "Calendar name (optional)" } }, required: ["eventId"] } }, { name: "find_free_slots", description: "Find available time slots in the calendar", inputSchema: { type: "object", properties: { startDate: { type: "string", description: "Start date (ISO 8601 format)" }, endDate: { type: "string", description: "End date (ISO 8601 format, optional, defaults to 7 days from start)" }, duration: { type: "number", description: "Duration in minutes (optional, defaults to 30)" }, workDayStart: { type: "number", description: "Work day start hour (0-23) (optional, defaults to 9)" }, workDayEnd: { type: "number", description: "Work day end hour (0-23) (optional, defaults to 17)" }, calendar: { type: "string", description: "Calendar name (optional)" } }, required: ["startDate"] } }, { name: "get_attendee_status", description: "Check the response status of meeting attendees", inputSchema: { type: "object", properties: { eventId: { type: "string", description: "Event ID" }, calendar: { type: "string", description: "Calendar name (optional)" } }, required: ["eventId"] } }, { name: "get_calendars", description: "List available calendars", inputSchema: { type: "object", properties: {} } } ] };
- src/index.ts:587-605 (handler)MCP callTool request handler that validates inputs, invokes the OutlookManager.searchSentEmails method, and formats the response as MCP content.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') }, ], }; }
- src/outlook-manager.js:481-485 (helper)JavaScript version of the handler function (imported by index.ts), identical logic to TS version.async searchSentEmails(query, count = 10) { 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);