Skip to content
be-human.ai
← Back to the journal

Tools & integrations

Gmail and Outlook Access for AI Agents: Scopes That Stay Safe

Give an AI agent Gmail or Outlook access limited to specific folders and actions, with approval gates, audit logs and tests that run before go-live.

Be Human typographic cover with the title: Gmail and Outlook Access for AI Agents: Scopes That Stay Safe
Conceptual illustration created with AI · Be Human

To give an AI agent access to Gmail or Outlook safely, grant the narrowest provider permission the task needs, then enforce folder, label and action limits in the layer that sits between the agent and the mailbox. Provider scopes usually apply to the whole account, so a read-only or draft-only permission does not by itself confine the agent to one folder or label. Limit the agent to a defined stream of messages, separate reading from drafting and sending, and record every action so a person can check the work.

Key takeaways

  • Start from one task and one stream of mail, not the full account.
  • Request read, draft and send permissions separately, and avoid full mailbox control unless the job truly requires it.
  • Enforce folder and label boundaries in your own tool layer, because most provider scopes cover the whole mailbox.
  • Keep sending behind human approval until the agent passes a written test set.
  • Log each read and each proposed action with a reason, so a reviewer can trace what happened.

What access does an agent actually need?

Most useful email work splits into four activities: reading messages, labeling them, drafting replies and sending. A support triage agent, for example, usually needs to read incoming requests, apply an internal label and prepare a draft for a person to approve. It rarely needs to send mail on its own, and it has no reason to see payroll, legal or personal threads that happen to sit in the same inbox.

Before you open any connection, write down those activities in plain language. For each one, decide whether the agent may perform it alone, whether it may perform it only after a person approves, or whether it should never perform it. This list becomes the basis for every permission that follows. If the list cannot be written in a few lines, the task is not yet ready for an agent. For a broader view of how one agent can reach several channels, see connect an AI agent to email without risking your inbox.

Why provider scopes alone are not enough

Google's OAuth 2.0 model asks an application to request specific scopes, and Gmail offers separate scopes for read-only access, message and label changes, composing drafts and sending. Microsoft Graph similarly separates reading mail, reading and writing mail, and sending mail for Outlook. These distinctions matter, and you should always choose the narrowest one that supports the task.

They do not, in most cases, restrict access to a single folder or label. A Gmail read scope generally lets the application read messages across the account, whatever label they carry. An Outlook delegated permission generally follows the signed-in user's mailbox. Folder and label boundaries therefore have to be enforced somewhere else. In Exchange Online, application access policies can limit an app registration to a defined set of mailboxes or mail-enabled security groups, which is a useful control when an agent runs as an application rather than as a user. Check the current provider documentation before relying on any specific mechanism, because the available controls change. The [Google OAuth 2.0 documentation](https://developers.google.com/identity/protocols/oauth2) explains how scopes are requested and granted, and it is a good starting point for the Gmail side. For a comparison of how Google Workspace and Microsoft 365 setups differ, see AI agent Google Workspace and Microsoft 365: grant only what it needs.

The provider decides what the connection can reach. Your tool layer decides what the agent is allowed to ask for.

A step-by-step plan for scoping mailbox access

  • First, choose one role and one stream. A practical example is a dedicated label, named for a single queue, populated by a filter that a person owns and can change.
  • Second, give the agent its own mailbox or account where the business allows it, so the agent's identity never equals the owner's identity.
  • Third, request the narrowest provider scope for each activity, and write down why each scope is needed.
  • Fourth, enforce the label boundary in the read tool. The tool accepts only the approved label identifier and returns a refusal for any other request, whatever the model asks for.
  • Fifth, implement drafting as creating a draft object, never as sending. Sending belongs to a separate tool that will not run without an approval record.
  • Sixth, define how the agent handles unknown senders, attachments and links, and which cases it must hand to a person without attempting a reply.
  • Seventh, log each read, label change and draft with a timestamp, the message identifier, a reason and the rule that allowed the action.
  • Eighth, run a written test set before go-live, and repeat it after every permission or prompt change.

Decide which actions need approval

Use three tiers. The first tier contains actions the agent performs alone: reading messages inside the approved label, applying an internal label, and adding a note to the internal case record. The second tier contains actions the agent prepares and a person approves: drafted replies, forwarding to a named internal team, and moving a message out of the queue. The third tier contains actions the agent never performs: sending to external addresses without approval, deleting messages, changing filters or forwarding rules, sharing access with other people, and anything that involves money, contracts or signatures.

A short decision guide helps when a new action appears:

  • If the action changes what someone outside the company receives, it needs approval.
  • If the action stays inside the mailbox, is easy to reverse and touches only the approved label, the agent may perform it alone.
  • If the action changes filters, forwarding, delegation or permissions, it stays with a person.
  • If the action commits money, a signature or a legal position, it stays with a person even when the draft is ready.

The reasoning behind separating drafting from sending is covered in more depth in read, draft and send: three different AI permissions.

How do you protect the agent from instructions hidden in email?

Email is untrusted input. Any sender can write text that looks like an instruction, including a message that asks the agent to forward a thread or ignore its rules. The OWASP guidance on prompt injection recommends treating content from external sources as data rather than as commands, and designing the system so that a persuaded model still cannot do much harm. For mailbox agents, that means recipient addresses taken from message text must be checked against an allowed list, forwarding rules cannot be changed by the agent, attachments are read in a restricted way, and any action that leaves the company goes through the approval step.

An illustrative scenario: a supplier email contains a line asking the agent to send the latest order summary to an address outside the company. The agent treats the line as content to summarize, not as a request to act. It creates a review item for the purchasing lead, because the address is outside the allowed list and the request did not come from a person through the agent's approved channel. No mail leaves the mailbox, and the review item records the message identifier for later checking.

The [OWASP prompt injection prevention cheat sheet](https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html) lists further patterns, and the [OWASP authorization guidance](https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html) explains why authorization checks belong in code that the model cannot rewrite.

How do you test and review mailbox access before go-live?

Build a test label with seeded messages that cover routine cases, unknown senders, a message asking for an external send, a message with an instruction embedded in its body, and a message placed just outside the approved label. Write the expected result for each case before the first run. Expected results usually look like this: reading inside scope is allowed, reading outside scope is refused, a draft is created, and an external send is blocked and routed for review. Run the tests against a staging mailbox rather than the live inbox, and repeat them whenever a scope, label, filter or prompt changes.

Review the logs as an operations task, not only as a developer task. A business owner or operations lead should be able to see what the agent read, what it drafted, what it proposed to send and what a person approved. Review the logs weekly during the first month, then move to a monthly rhythm once the pattern is stable and the test set keeps passing. Any unexpected read outside the label is an incident, even if no harm followed, because it shows that a boundary did not hold.

In a Be Human engagement, the first deliverable defines one role, the mail stream it may read, the labels it may apply, the drafts it may create and the actions that always wait for a person. The provider scope is set to the smallest option that works, and the folder and action rules are enforced in the agent's tool layer, where they can be tested. Managed operations then cover recurring permission reviews, monitoring of the logs, maintenance when the mail provider or the connection changes, and incident response if a boundary fails. The service is remote and available in English and Portuguese.

If you are not yet sure which mailbox task should go first, the free Be Human AI diagnostic can help you find the first task worth handing to an agent.

Frequently asked questions

Can I limit a Gmail agent to a single label? Usually not through the provider scope alone, so the boundary has to live in your own tool layer. Create a dedicated label fed by a filter that a person controls, and make the agent's read tool accept only that label identifier. Test with messages outside the label to confirm that the refusal happens in code, not only in the prompt.

Should an AI agent ever send email on its own? Only for a narrow, low-risk message type that a person has approved in writing, such as an automated acknowledgment with fixed wording and a fixed recipient rule. Most business agents should prepare drafts for a person to send, at least until the test set and the logs show stable behavior over a sustained period. Any new message type should return to the approval tier before it is widened.

What should the agent do if the mailbox connection expires? The agent should stop the affected task, avoid retrying with broader credentials, and alert a person with enough context to restore the connection safely. Keep the failed action in a queue so it can be reviewed rather than silently repeated. The process for this is described in what should an AI agent do when a connection expires?.

Is a dedicated mailbox better than the owner's inbox? In most cases yes, because the agent's identity, permissions and logs stay separate from the owner's personal and executive mail. A dedicated support or operations address also makes the stream easy to define, since only the messages that belong to the role arrive in it. Keep the owner's inbox out of the agent's scope entirely unless a specific, reviewed task requires a forward from it.

Your next step

See where an AI agent fits in your company first.

Take the free Be Human AI diagnostic. A few questions about your work show which task to hand to an agent first, what it needs to know and where a person approves.

Be Human editorial guidance. Examples are illustrative unless explicitly attributed. Sources provide background; implementation choices depend on your workflow.

Less busywork. More room for you.

Bring us the work you wish you had time for.

Book a call to try a personalized AI agent free for 7 days ↗Or take the free AI diagnostic →