search_emails
Find specific emails in Gmail using advanced search queries. Filter messages by sender, recipient, subject, attachments, date, or read status to locate relevant correspondence quickly.
Instructions
Search for emails using Gmail's search syntax.
This tool searches for emails matching the specified query using
Gmail's powerful search syntax.
Prerequisites:
- The user must be authenticated. Check auth://status resource first.
- If not authenticated, guide the user through the authentication process.
Args:
query (str): The search query using Gmail's search syntax.
Examples:
- "from:example@gmail.com" - Emails from a specific sender
- "to:example@gmail.com" - Emails to a specific recipient
- "subject:meeting" - Emails with "meeting" in the subject
- "has:attachment" - Emails with attachments
- "is:unread" - Unread emails
- "after:2023/01/01" - Emails after January 1, 2023
max_results (int, optional): Maximum number of emails to return. Defaults to 10.
Returns:
Dict[str, Any]: The search results including:
- query: The search query used
- emails: List of email objects matching the query with links
- next_page_token: Token for pagination (if applicable)
Example usage:
1. First check authentication: access auth://status resource
2. If authenticated, search for emails: search_emails(query="from:example@gmail.com")
3. If not authenticated, guide user to authenticate first
4. Always include the email_link when discussing specific emails with the user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| max_results | No |