ConnectOnionConnectOnion
DocsOutlook

Outlook

Give your agents full Outlook access via Microsoft Graph API. Read, search, send, and manage emails.

Quick Start

quickstart.py
1from connectonion import Agent, Outlook 2 3outlook = Outlook() 4agent = Agent("assistant", tools=[outlook]) 5 6agent.input("Show me my recent emails") 7agent.input("Send an email to alice@example.com saying hello")

Setup

Authenticate with Microsoft:

Terminal
$co auth microsoft

Your agent can now read and manage Outlook emails.

Agent Methods

Reading Emails

read_inbox(last=10, unread=False)

Read emails from inbox

  • last - Number of emails (default: 10)
  • unread - Only unread emails (default: False)

get_sent_emails(max_results=10)

Get emails you sent

get_email_body(email_id)

Get full email content with headers

Search

search_emails(query, max_results=10)

Search emails using Microsoft Graph search

Example queries:

  • "quarterly report"
  • "meeting notes"
  • "invoice"

Sending Emails

send(to, subject, body, cc=None, bcc=None)

Send email via Microsoft Graph API

  • to - Recipient email (comma-separated for multiple)
  • subject - Email subject
  • body - Email body (plain text)
  • cc - Optional CC recipients
  • bcc - Optional BCC recipients

reply(email_id, body)

Reply to an existing email

Actions

mark_read(email_id)

Mark email as read

mark_unread(email_id)

Mark email as unread

archive_email(email_id)

Move email to archive folder

Stats

count_unread()

Count unread emails in inbox

get_my_email()

Get connected Microsoft email address

Complete Example

complete_example.py
1from connectonion import Agent, Outlook, Memory 2 3outlook = Outlook() 4memory = Memory() 5 6agent = Agent( 7 name="email-assistant", 8 tools=[outlook, memory], 9 system_prompt="You help manage Outlook emails and remember important info." 10) 11 12# Various tasks your agent can now do: 13agent.input("Check unread emails and summarize them") 14agent.input("Send an email to alice@example.com about the project update") 15agent.input("Find all emails about the quarterly report") 16agent.input("How many unread emails do I have?")

Troubleshooting

Missing Microsoft Mail scopes

Run co auth microsoft

Credentials not found

Run co auth microsoft

Token expired

Tokens auto-refresh. If issues persist, run co auth microsoft again.

Related