The issue here is a fundamental mismatch between natural language and the API query language that the Outlook connector uses under the hood.
When you pass the agent's dynamic string directly into the Get emails (V3) connector, Copilot is likely passing the user's entire raw sentence ("find me the most recent...") into the Search Query field. The Outlook API does not process natural language. It expects rigid KQL (Keyword Query Language) syntax. When you feed it a full sentence, the API parses it as a massive "OR" search, pulling random garbage from Archive, Sent, or Deleted folders simply because those emails contain common words like "find" or "recent."
To fix this, you must physically bridge the gap between the AI's natural language and the API's hard syntax:
- Constrain the AI's Extraction: Instead of a generic
search_queryinput, rename your input variable tosender_email. In the input's description box, explicitly instruct the AI: "Extract only the exact email address from the user's prompt." - Hardcode the KQL Prefix: In the
Get emails (V3)action setup, go to the Search Query field and physically typefrom:followed immediately by your dynamicsender_emailvariable (so the final execution reads exactly likefrom:******@in4uclouud.com). - Lock the Folder Path: Click the Folder dropdown in the action and physically select Inbox. Do not leave this as an AI-populated variable. The AI does not know your tenant's internal Exchange Folder IDs, and if it guesses, the connector will default to searching the entire mailbox tree.
- Limit the Array: Set the Top or Fetch parameter to
1so the array only returns the absolute most recent hit.
Are you adding this connector natively as a Copilot Studio Plugin Action, or are you routing the logic through a Power Automate Cloud Flow?