Back to Blog

Querying My Email Archive with OpenClaw

Javier Callico

Two weeks ago, I installed Linux on an old laptop I had sitting around and started experimenting with OpenClaw.

I already had a job in place to back up all my emails to a local OneDrive folder.

I asked OpenClaw to implement a solution to index and query my emails. See the conversation log below. What is most impressive is that all this was done using a lightweight model (Gemini 3 Flash).

Thoughts: The point of this experiment is to highlight the possibilities of this emerging technology. While I am currently communicating with OpenClaw using my own Telegram bot, I expect all operating systems to become agentic and natively support this kind of automation very soon. Native applications won’t need a rigid, traditional UI anymore—just an API for local agents to interact with. Soon, all that will be needed on our phones is a prompt. From there, the OS will simply generate temporary, dynamic interfaces on the fly, giving us exactly the visual elements we need for the task at hand before dissolving away.

———

Me:
All my emails are backed up to the following location: "/mnt/work/OneDrive/My\ Emails/". For each email, there is a corresponding .eml file.

I would like to find a way to index all these emails so it is easy for us to search on them. Please suggest different ways to accomplish this. Once we settle on a solution, we can then create a job to index any new email every morning (at 7:05 AM EST).

OpenClaw:
I've analyzed your email backup. You have approximately 42,666 .eml files. Since this is a significant volume of data, here are three ways we can index them to make them searchable for you:

Option 1: Semantic Search (Semantic Memory)

This is the "Smart" option. We use OpenClaw's built-in memory system to "read" and understand your emails.

• How it works: I index the contents using an embedding model (like Gemini).
• Pros: You can search by meaning. For example: "Find the email where I discussed the server migration last year" (even if the word 'migration' isn't exactly in the subject).
• Cons: High initial resource usage. Indexing 42k emails will take some time and consume API tokens for the initial pass.

Option 2: Metadata & Full-Text Search (SQLite Database)

This is the "Technical" and high-performance option.

• How it works: I write a local script to parse every .eml file and extract the Date, From, To, Subject, and a plain-text snippet of the Body into a local SQLite database file.
• Pros: Extremely fast and precise. I can filter by date range, sender, or specific keywords in seconds. It runs entirely locally with zero API cost.
• Cons: It doesn't "understand" context as well as Option 1; it relies on finding specific words.

Option 3: Direct File Search (Ripgrep)

This is the "Lightweight" option.

• How it works: I install ripgrep (a very fast search tool) and search the raw files whenever you ask.
• Pros: No database to maintain. Very simple.
• Cons: Slower than the other options for 42k files. Parsing complex MIME/HTML emails on the fly can be messy.

───

My Recommendation:
I recommend Option 2 (SQLite) for your primary index. It will be the most reliable and cost-effective way to handle 42,000+ emails while giving me the ability to answer questions like "Show me all emails from Javier in 2024."

We can then add Option 1 for a subset of your most recent or important emails if you need natural language "vibes" search.

Which approach would you like to start with?

Me:
Proceed with the implementation of Option 2

OpenClaw:

Option 2 is currently being implemented and is already working!

Here is the progress:

  1. Database Created: I've set up a local SQLite database (emails.db) to store the sender, recipient, subject, date, and a snippet of the email body.
  2. Indexing in Progress: I have a background process running right now to parse all 42,666 of your emails. As of a few moments ago, it has already indexed over 11,300 emails.
  3. Scheduled Job: I've created a recurring task that will run every morning at 7:05 AM EST to check for and index any new .eml files added to your OneDrive.

You don't need to wait for it to finish the full 42k to start using it. I can already search the portion that has been indexed.

Would you like to try a test search, or should I just notify you once the full historical index is complete?

I tested it with a couple of cases and it worked pretty good.

Me:
Can you put together a detailed explanation of how our email backup, indexing and querying solution works?

OpenClaw:
I have great news: the historical indexing of all 42,666 of your emails is now complete!

Here is a detailed breakdown of how your new Email Intelligence Solution works:

1. The Data Source (Backup)

Your emails are stored as standard .eml files in your OneDrive mount:

 /mnt/work/OneDrive/My Emails/jcallico_at_xxxxxxx.com/

These files contain the full headers, text, and metadata for every message.

2. The Indexing Engine

I've implemented a custom Node.js system to turn those raw files into a searchable format:

• Parsing: Using the mailparser library, I "read" each email to extract the Sender, Recipient, Subject, Date, and a Text Snippet (the first 1,000 characters).
• Deduplication: The system tracks the file path of every indexed email. If a file is already in the index, it skips it, making future updates very fast.

3. The Brain (SQLite Database)

All the extracted information is stored in a local database file:

/home/javier/.openclaw/workspace/emails.db

• Speed: Searching this structured database takes milliseconds, whereas searching 42,000 text files manually would take minutes.
• Privacy: This is a 100% local solution. Your email content never leaves your machine (LEGION) during the indexing process.

4. Daily Automation

To keep everything current, I've scheduled a Daily Indexing Job (index-new-emails):

• Schedule: Every morning at 7:05 AM EST.
• Function: It scans for any new .eml files added to your OneDrive in the last 24 hours and adds them to the database automatically.

5. How We Query It

When you ask me a question (like the Primerica test), I perform the following steps:

  1. Analyze: I determine the keywords and dates relevant to your request.
  2. SQL Query: I generate a specific command to search the database.
  3. Summarize: I review the results found in the database and provide you with a natural language summary or locate specific files.

The system is now fully operational and ready for any other searches you might have!