DEV Community

Cover image for Outlook Can't Search Multiple Categories — So I Built It
Akshay Jatin Solanki
Akshay Jatin Solanki

Posted on

Outlook Can't Search Multiple Categories — So I Built It

Outlook Can't Search Multiple Categories — So I Built It

I use Outlook categories heavily to organise email.

Project. Client. Follow Up. Important. Finance.

The problem came later.

Once I had several categories assigned to hundreds or thousands of emails, I wanted to do something simple:

"Show me emails that have BOTH Project AND Follow Up."

Or:

"Show me emails that have Finance OR Client."

That is where Outlook's native search became frustrating.

So instead of continuing to manually scroll through folders and emails, I built my own multi-category search tool using Outlook VBA.

View the project on GitHub →

What I Built

The tool adds a dedicated search panel to Classic Outlook on Windows.

You can select multiple categories and choose how they should be matched:

  • AND — an email must contain all selected categories
  • OR — an email must contain at least one selected category

Then you can further narrow the results using additional filters.

Before vs After

Here's the kind of problem that led me to build it.

Imagine you have an email history containing:

500+ emails
↓
Categories:
Project
Client
Follow Up
Finance
Important
Enter fullscreen mode Exit fullscreen mode

You want:

Find emails tagged Project + Follow Up from a particular sender, received this month, including only messages with attachments.

Before

The workflow becomes a collection of manual steps:

1. Open Outlook search
2. Filter by category
3. Check results manually
4. Try another filter
5. Open messages one by one
6. Repeat across folders/subfolders
7. Remember which emails you already checked
Enter fullscreen mode Exit fullscreen mode

The more conditions you add, the more tedious it becomes.

After

With the VBA search panel:

Categories:
☑ Project
☑ Follow Up

Match:
◉ AND
○ OR

Sender:
client@example.com

Date:
01 Sep → 30 Sep

Attachments:
☑ Only emails with attachments

Scope:
Inbox + Subfolders
Enter fullscreen mode Exit fullscreen mode

Then:

Click Search.

The results are returned in a single grid showing the subject, sender, received date, categories and folder.

From there you can double-click an email, export the results to Excel, or save the matched emails to another Outlook folder.

That was the whole idea behind the project:

Turn a frustrating manual search into one repeatable query.

Features

Feature What it does
Multi-category search Search multiple Outlook categories together using AND / OR logic
Scope control Search the Inbox, subfolders, whole mailbox, or shared mailboxes
Sender filter Filter results by sender
Keyword filter Search subject or email body
Attachment filter Find emails with attachments
Date range Filter emails by received date
Results grid View subject, sender, date, categories and folder
Open email Double-click a result to open the message
Export to Excel Export the result list
Save to folder Move or copy matched emails to another Outlook folder

Everything runs locally inside Outlook.

There is no external server, third-party service, or data upload involved.

Why I Built It

The interesting part wasn't really the VBA form.

The real problem was information retrieval.

I had already done the work of categorising my emails. The categories contained useful information about the context of each message.

But once there were many categories, finding the exact combination I needed became difficult.

I wanted something that felt less like manually navigating an email client and more like querying my own organised email history.

So the workflow became:

Categorise → Select conditions → Search → Get the exact matching emails

The Technical Part

One of the most important implementation decisions was avoiding a simple loop through every Outlook mail item.

A straightforward approach would look something like this:

For Each objItem In objFolder.Items
    ' Inspect the email
Next
Enter fullscreen mode Exit fullscreen mode

That works, but it becomes increasingly expensive as the mailbox grows.

Instead, the tool uses Outlook's Folder.GetTable functionality.

Dim objTable As Outlook.Table

Set objTable = objFolder.GetTable( _
    Filter:=strDASL, _
    Columns:="Subject,ReceivedTime,SenderName,Categories,EntryID")
Enter fullscreen mode Exit fullscreen mode

The idea is simple:

Read the properties required for the search without fully opening every email.

This keeps the search process lightweight, particularly when working with larger mail folders.

Exact Category Matching Matters

There is another small detail that can cause surprisingly bad search results.

Imagine you have these categories:

HR
HRS
HR-Policy
Enter fullscreen mode Exit fullscreen mode

A simple substring test such as:

If InStr(1, strCats, "HR", vbTextCompare) > 0 Then
Enter fullscreen mode Exit fullscreen mode

can produce false matches.

The tool therefore uses token-based category matching so that HR is treated as a distinct category rather than simply matching text containing HR.

That sounds minor, but it makes the search results much more trustworthy.

Search Scope

Another thing I wanted was control over where the search happens.

The tool supports searching across different scopes rather than forcing everything into a single folder.

That means you can use the same search idea for:

Inbox
Inbox + Subfolders
Whole Mailbox
Shared Mailboxes
Enter fullscreen mode Exit fullscreen mode

This becomes especially useful when Outlook rules have already distributed emails across multiple folders.

The Results Window

The search results are presented in a grid containing information such as:

Subject
Sender
Received Date
Categories
Folder
Enter fullscreen mode Exit fullscreen mode

From there, you can open a message directly, export the result list to Excel, or save the matching emails to another Outlook folder.

So the tool is not only a filter — it is intended to be a small workflow around finding and acting on the results.

Installation

The project is VBA-based, so there is no traditional installer.

1. Open Outlook's VBA Editor

Press:

Alt + F11
Enter fullscreen mode Exit fullscreen mode

2. Import the VBA module

Import:

modCategorySearch.bas
Enter fullscreen mode Exit fullscreen mode

3. Create the two UserForms

Create:

frmCategorySearch
frmResults
Enter fullscreen mode Exit fullscreen mode

Then paste the corresponding form code from the repository.

4. Run the macro

Run:

ShowCategorySearch
Enter fullscreen mode Exit fullscreen mode

You can also add the macro to Outlook's Quick Access Toolbar.

The complete installation instructions are available in the repository README.

Project Structure

Email_Categorizer_outlookvba/
├── modCategorySearch.bas
├── frmCategorySearch_code.txt
├── frmResults_code.txt
└── Smart_Email_Search_no_logo.png
Enter fullscreen mode Exit fullscreen mode

Privacy

This was designed as a local productivity tool.

The repository does not require a web service or external backend.

The search runs through Outlook VBA on the user's machine.

Limitations

This project is intentionally built around Classic Outlook on Windows and VBA.

That also means it comes with the limitations of Outlook VBA itself.

There is no modern web-based add-in architecture here, and installation currently involves importing the module and creating the required UserForms.

For this project, that trade-off was acceptable because the goal was straightforward:

Make searching my categorised Outlook mail significantly easier without introducing an external application.

What I Want to Improve Next

There are several directions I'd like to explore:

  • Easier installation
  • Saved search presets
  • More advanced search combinations
  • A more polished interface
  • Potentially a proper Outlook add-in implementation

But for now, the VBA version solves the problem I originally set out to solve.

Try It

If you use Outlook categories heavily and have ever wished you could search several of them together, you can check out the project here:

⭐ GitHub — Outlook VBA Multi-Category Search

The project is released under the MIT License.

I'd especially be interested in hearing from people who use large Outlook mailboxes and have found other limitations in Outlook's native category/search workflow.


Built because sometimes the best way to fix a productivity problem is to build the missing feature yourself.

Top comments (0)