Skip to main content
AgentMailLoader streams messages from an AgentMail inbox as LangChain Documents—one document per message, plain-text body as page_content, sender / subject / labels / thread / attachment metadata on metadata. Useful for indexing an inbox into a vector store for RAG over email.

Overview

ClassPackage
AgentMailLoaderlangchain-agentmail

Setup

Install the package:
Set your AgentMail API key (get one at agentmail.to):

Instantiation

Load

Each Document includes the following metadata keys (when present):
  • inbox_id, message_id, thread_id
  • from, to, cc, subject, labels, timestamp
  • has_attachments, attachments: a list of {attachment_id, filename, content_type, size}
To download attachment bytes, pair the loader with AgentMailGetAttachmentTool from the toolkit—it returns a presigned download URL.

Lazy load

For larger inboxes, stream documents one at a time instead of materializing the full list:

Indexing into a vector store

API reference

The package source lives at github.com/agentmail-to/langchain-agentmail.