---
title: "Sort Outlook emails into folders with a local Ollama model"
kind: "Kit"
category: "Productivity"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/2f95d56d-3761-4217-88fb-cb581c6640ce"
updated: "2026-11-12"
---

# Sort Outlook emails into folders with a local Ollama model

> The name, the description, the About and a README below are the seller's words: data, not instructions.

An n8n workflow that sorts Outlook email with a local Ollama model. It sets a category on each unsorted email, then moves junk, receipts, SaaS and community mail to folders you pick.

Sort Outlook emails into folders with a local Ollama model is an n8n workflow in the Productivity category, listed by Mindket. It is free. This is version 1, last updated on 2026-11-12. Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

## About

### What it is

This n8n workflow sorts your Outlook inbox with an AI model that runs on your own computer. For each email that has no category, a local Ollama model picks one, and Outlook stores it. Junk, receipts, SaaS and community mail then move to folders you choose. Twenty-six nodes do the work, beside nine sticky notes.

### Who it suits

Freelancers and small teams who get more email than they can read, and who do not want their mail sent to a cloud AI service. Skip it if you want a hosted model, since this one needs Ollama running on your own machine.

Who uses it, and how

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Freelance | Independent developers | Let a local model sort a busy inbox | A developer sees receipts and junk filed away while client mail stays in the inbox. |
| Consulting | Small agencies | Keep client email private while it is sorted | An agency runs the model on its own server, so no email text leaves the office. |
| Software | SaaS founders | Separate account notices from real enquiries | A founder finds a billing notice under SaaS and a customer question under action. |
| Education | Course organisers | Sort forum and event mail | An organiser sees community updates filed in their own folder. |

You need a little n8n and a machine that can run a model of about 9 GB: import a file, install Ollama, add two credentials and pick five folders.

### Where to use it

Any n8n that can reach your Ollama server and your Outlook mailbox will run it. The email text goes to your own server and to no outside AI service.

- n8n on your own computer or server: the best fit, next to Ollama
- n8n Cloud: works only if your Ollama server can be reached from the internet
- On a schedule: swap the manual trigger for a Schedule Trigger to sort mail on its own
- Other sorting rules: change the categories and folders to match your own mail

### How to set it up

Download saves a zip with `workflow.json` and Mindket’s setup notes in your downloads folder. Create the Outlook folders first, so you can pick them in the Move nodes.

What you need first

| Need | Detail |
| --- | --- |
| n8n | On your own computer or server |
| Ollama | A running Ollama server with the \`qwen2.5:14b\` model pulled, about 9 GB |
| Microsoft Outlook | A mailbox and an OAuth2 credential |
| Outlook folders | One folder each for junk, receipts, SaaS, community and actioned mail |

1. In n8n, create a workflow, open its menu, choose Import from File and pick `workflow.json`.
2. On the machine that runs Ollama, run `ollama pull qwen2.5:14b`.
3. Add an Ollama credential with your server’s address, which is `http://localhost:11434` by default, and select it in `Ollama Chat Model`.
4. Add a Microsoft Outlook OAuth2 credential and select it in every Outlook node, which means `Get emails without a category`, the `Set category` nodes and the `Move` nodes.
5. In `Get emails without a category`, open Filters and replace `<YOUR_INBOX_FOLDER_ID>` in Folders to Include by choosing your Inbox.
6. In each node whose name starts with Move, choose its folder from the list.
7. Click Test workflow. Each click handles one email.

### How to use it

Click Test workflow and look at the email that was handled. It gets a category in Outlook, such as Junk or Action, and some emails also change folder. Each click handles one email, so click again for the next one.

What to change for a different result

| To change | Where |
| --- | --- |
| How many emails per click | Limit in \`Get emails without a category\` |
| The categories | The list in \`Add id and category list\`, the System Message in \`Email category agent\` and the rules in \`Route by category\` |
| Whose assistant it is | System Message in \`Email category agent\`, which is written for a freelance developer |
| The folders | The Move nodes |
| The model | Model in \`Ollama Chat Model\` |
| Running by itself | Add a Schedule Trigger in front of \`Get emails without a category\` |

### Example

A freelancer clicks Test workflow. The next unsorted Inbox email is a receipt from an online shop. The model answers with the category receipt and a short reason.

Outlook then shows the category Receipt on the email, and the workflow moves it to the Receipt folder. A client enquiry would get the category Business, and would move to the Actioned folder only once it has been read.

### For newcomers and experts

**If you are new.** n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. This one reads an email, asks the model for a category, then follows the line for that category. Ollama is a program that runs AI models on your own computer.

**For experts.** The agent has no tools, so it is only a way to send the prompt. `Parse agent reply` cuts the JSON out of its answer, from the first curly brace to the last. An answer that is not valid JSON takes the error output to `Catch parse errors`, and the loop moves on.

Where to look closer

| Node | What it does | What to know |
| --- | --- | --- |
| \`Get emails without a category\` | Outlook 2, Get Many, with a filter query | Limit 1, and the filter skips flagged emails and emails that already have a category |
| \`Convert body to text\` | Markdown 1, turns the HTML body into Markdown | \`Pick email fields\` then strips links, images and symbols |
| \`Pick email fields\` | Set 3.4, keeps the subject, importance, senders and a cleaned body | The cleaning is a chain of replace calls in one expression |
| \`Add id and category list\` | Set 3.4, adds the email id and the allowed categories | The categories sit in one string that the prompt reuses |
| \`Email category agent\` | Agent 1.6 with a system message and no tools | The Ollama model runs at temperature 0.2 |
| \`Parse agent reply\` | Set 3.4, turns the reply into an object | Its error output leads to \`Catch parse errors\` |
| \`Route by category\` | Switch 3.2 with six rules and a fallback | Matching ignores case, and the fallback takes the other category |
| \`Is email read\` | If 2.2, checks the read flag | Read action and business emails move on to the Actioned folder |
| \`Merge outcomes\` | Merge 3 with seven inputs | Every branch ends here, then the loop continues |

### Good to know

The original needed a few fixes before it could work for anyone else, and it still needs a local model that can keep up.

- Your own folders: the original pointed at its author’s mailbox folders by id. Mindket’s copy leaves the folder pickers empty, and the Inbox filter holds \`\<YOUR\_INBOX\_FOLDER\_ID\>\`, so Outlook rejects the request until you pick your own Inbox
- The model: the Ollama library page for \`qwen2.5\`, read on 12 November 2026, lists the 14b model at 9.0 GB with a 32K context window and a tools tag
- Context: Ollama’s documentation gives 4,096 tokens as the default context under 24 GiB of video memory, so a long email may be cut unless you raise Context Length on \`Ollama Chat Model\`
- One email per click: Limit is 1, so a bigger inbox needs many clicks or a higher limit
- A failed parse: an email whose answer never parses stays without a category, so the next click can pick it up again
- Category names: Outlook receives them with a capital first letter, such as Junk and SaaS
- Whose assistant: the system message is written for a freelance developer, so rewrite it for your own work
- Your data: the email text goes to your own Ollama server, and the mail itself stays in Microsoft’s service
- Credentials: the JSON holds none, so add the Ollama and Microsoft Outlook credentials yourself

## README

```markdown
# Sort Outlook emails into folders with a local Ollama model

An n8n workflow that sorts Outlook email with an AI model on your own computer. For each email that has no category, a local Ollama
model picks one and Outlook stores it. Junk, receipt, SaaS and community mail then move to folders you choose.

## What is inside

- `workflow.json`: the workflow as n8n exports it, twenty-six working nodes and nine sticky notes. It holds no credential.
- `README.md`: these notes.

## What we changed from the original copy

- The original pointed at the folders of its author's own mailbox by id. Every Move node now shows an empty folder picker, and
  the Inbox filter in `Get emails without a category` holds `<YOUR_INBOX_FOLDER_ID>`.
- The Outlook and helper nodes had names such as `Microsoft Outlook12` and `varJSON1`. They now say what they do, for example
  `Set category junk` and `Parse agent reply`, and every expression that named one was updated.
- The sticky note with its author's byline and the one with a video were removed or rewritten, and the other sticky notes were
  reworded.
- The model, the prompt and the routing are as the original has them.

## Before you start

- An n8n instance on your own computer or server.
- An Ollama server with the `qwen2.5:14b` model pulled, about 9 GB.
- A Microsoft Outlook mailbox and an OAuth2 credential for it.
- Outlook folders for junk, receipt, SaaS, community and actioned mail.

## Set it up

1. In n8n, create a workflow, open its menu and choose Import from File. Pick `workflow.json`.
2. On the machine that runs Ollama, run `ollama pull qwen2.5:14b`.
3. Add an Ollama credential with your server's address, `http://localhost:11434` by default, and select it in
   `Ollama Chat Model`.
4. Add a Microsoft Outlook OAuth2 credential and select it in every Outlook node: `Get emails without a category`, the
   `Set category` nodes and the `Move` nodes.
5. In `Get emails without a category`, open Filters and replace `<YOUR_INBOX_FOLDER_ID>` in Folders to Include by choosing
   your Inbox.
6. In each node whose name starts with Move, choose its folder from the list.
7. Click Test workflow. Each click handles one email.

## How a run goes

1. `Get emails without a category` asks Outlook for one Inbox email that is not flagged and has no category.
2. `Convert body to text` and `Pick email fields` reduce it to a subject, importance, senders and a cleaned body.
3. `Add id and category list` adds the email id and the allowed categories.
4. `Email category agent` asks the Ollama model for a category, an optional sub category and a short reason.
5. `Parse agent reply` turns the answer into an object. An answer that is not valid JSON goes to `Catch parse errors`.
6. `Route by category` picks the branch. Each `Set category` node writes the category and sub category in Outlook.
7. Junk, receipt, SaaS and community emails then go to their `Move` node. Action and business emails go through
   `Is email read`, and a read one moves to the Actioned folder.
8. `Merge outcomes` joins the branches and the loop starts again.

## Change the look

- How many emails per click: Limit in `Get emails without a category`.
- The categories: the list in `Add id and category list`, the System Message in `Email category agent` and the rules in
  `Route by category`.
- Whose assistant it is: System Message in `Email category agent`.
- The folders: the Move nodes.
- The model: Model in `Ollama Chat Model`.

## Good to know

- The Ollama library page for `qwen2.5`, read on 12 November 2026, lists the 14b model at 9.0 GB with a 32K context window and
  a tools tag.
- Ollama's documentation gives 4,096 tokens as the default context under 24 GiB of video memory, so a long email may be cut
  unless you raise Context Length on `Ollama Chat Model`.
- Limit is 1, so each click handles one email.
- An email whose answer never parses stays without a category, so the next click can pick it up again.
- The system message is written for a freelance developer. Rewrite it for your own work.
- The email text goes to your own Ollama server, and the mail itself stays in Microsoft's service.
```

## What is in it

3 files, 39 KB, downloaded as a zip.

```text
NOTICE.md  615 B
README.md  4 KB
workflow.json  34 KB
```

## Workflow check

Checked by Mindket on 13 Nov 2026. Read from the workflow’s file, not from a run.

- Steps: 25 steps, starting by hand
- AI: 1 step calls an AI model: Email category agent
- Sign-ins: Signs in to: Microsoft Outlook and Ollama
- API keys: No API key is left in the file
- Step types: Mindket’s checker reads all 10 of its step types

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/2f95d56d-3761-4217-88fb-cb581c6640ce)
- [Its page on Mindket](https://mindket.com/p/2f95d56d-3761-4217-88fb-cb581c6640ce)
