Read Microsoft Outlook Emails
Microsoft Outlook Email Reader retrieves and indexes email subjects and bodies from Outlook mailboxes using Microsoft Graph API with Azure AD authentication.
Why it matters
Access and index your Microsoft Outlook emails to build a searchable knowledge base. This integration allows you to extract valuable information from your inbox for further analysis or retrieval.
Outcomes
What it gets done
Authenticate with Microsoft Entra ID for secure access.
Retrieve email subjects and bodies from a specified Outlook folder.
Index email content for efficient searching and retrieval.
Configure access using app registration and API permissions.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-reader-readers-microsoft-outlook-emails | bash Overview
Microsoft Outlook Email Reader
Microsoft Outlook Email Reader is a LlamaIndex integration that connects to Outlook mailboxes via Microsoft Graph API to retrieve and index email content. It fetches email subjects and bodies from specified folders and converts them into LlamaIndex document objects for use in AI pipelines, search systems, or knowledge bases. Use this reader when you need to programmatically access Outlook email data. It requires Microsoft Entra ID app registration with Mail.Read permissions and is designed for organizations with Microsoft 365 infrastructure and the ability to register apps in Azure AD with appropriate Graph API permissions.
What it does
Microsoft Outlook Email Reader is a LlamaIndex integration that retrieves emails from Outlook mailboxes and indexes their subject lines and body content. It connects via Microsoft Graph API using Azure AD (Microsoft Entra ID) app authentication to fetch emails from specified folders.
When to use - and when NOT to
Use this reader when you need to programmatically access and index Outlook email content. It performs on-demand retrieval of emails from specified folders in an Outlook mailbox.
Do NOT use this reader if you need real-time email monitoring or webhook-based triggers - it performs on-demand retrieval rather than continuous monitoring.
Inputs and outputs
You provide five required parameters: client_id, client_secret, and tenant_id from your Microsoft Entra ID app registration, plus user_email for the target mailbox and folder name (e.g., "Inbox"). You can also specify num_mails to limit the number of emails retrieved.
The loader returns LlamaIndex document objects containing the subject and body text of emails from the specified folder, ready for indexing or further processing in your LlamaIndex pipeline.
Integrations
This reader integrates with Microsoft Graph API for email retrieval and requires Microsoft Entra ID (formerly Azure AD) for authentication. It's built as a LlamaIndex reader, so it works within the LlamaIndex ecosystem and can feed documents into any LlamaIndex index or processing pipeline.
The app registration requires Mail.Read application permissions under Microsoft Graph with admin consent granted.
Who it's for
This reader is designed for organizations with Microsoft 365 infrastructure and the ability to register apps in Azure AD with appropriate Graph API permissions.
Installation and usage
Install the package:
pip install llama-index-readers-microsoft-outlook-emails
Basic usage example:
from llama_index.readers.outlook_emails import OutlookEmailReader
loader = OutlookEmailReader(
client_id="<Client ID of the app>",
client_secret="<Client Secret of the app>",
tenant_id="<Tenant ID of the Microsoft Azure Directory>",
user_email="<User Email Address>",
folder="Inbox",
num_mails=10,
)
documents = loader.load_data()
Before using the reader, you must create an app registration in Microsoft Entra ID with Microsoft Graph Application Permissions for Mail.Read, and grant admin consent for these permissions.
Source README
Microsoft Outlook Email Reader
pip install llama-index-readers-microsoft-outlook-emails
The loader retrieves emails from an Outlook mailbox and indexes the subject and body of the emails.
Prerequisites
App Authentication using Microsoft Entra ID (formerly Azure AD)
- You need to create an App Registration in Microsoft Entra ID. Refer here
- API Permissions for the created app:
- Microsoft Graph --> Application Permissions --> Mail.Read (Grant Admin Consent)
More info on Microsoft Graph APIs - Refer here
Usage
To use this loader, client_id, client_secret, and tenant_id of the registered app in Microsoft Azure Portal are required.
This loader fetches emails from a specified folder in an Outlook mailbox.
from llama_index.readers.outlook_emails import OutlookEmailReader
loader = OutlookEmailReader(
client_id="<Client ID of the app>",
client_secret="<Client Secret of the app>",
tenant_id="<Tenant ID of the Microsoft Azure Directory>",
user_email="<User Email Address>",
folder="Inbox",
num_mails=10,
)
documents = loader.load_data()
The loader retrieves the subject and body of the emails from the specified folder in Outlook.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.