n8n

How to Automate Outlook Email Categorization?

Tidy your Outlook inbox with AI that sorts and files emails for you. It reads each new message, assigns clear categories, and moves it to the right folder. Great for busy teams that want a clean inbox without manual work.

Here is how it runs. Outlook pulls messages that are not flagged and do not have any category. The flow loops through each email, converts the body to clean text, and sets key fields. An AI agent using an Ollama chat model decides on a category and subcategory. The output is forced into JSON and errors are caught so the process keeps going. A switch maps each category to the right Outlook actions. The email gets tagged with categories and moved to a matching folder. A read check controls where the message goes next, and results merge back to continue the loop.

To set it up, you need Microsoft Outlook with mail permissions and access to an Ollama server running the qwen2.5 14b model. Update the category map and folder IDs to match your mailbox. Expect faster inbox triage for shared mailboxes like sales or support, and more consistent tags across the team.

What are the key features?

  • Outlook email fetch with filters to skip flagged items and already categorized mail
  • Batch processing using a loop to handle large inbox volumes safely
  • Markdown conversion to clean the email body before analysis
  • AI classification using an Ollama chat model with stable settings
  • JSON enforcement and error catching to avoid broken runs
  • Category switch that maps AI results to exact Outlook actions
  • Outlook update to set one or two categories on each message
  • Outlook move actions that route emails into the right folders
  • Read status check to change routing based on whether a message was opened
  • Merge and loop control to continue processing without stopping on errors

What are the benefits?

  • Reduce manual sorting from 2 hours to 10 minutes per day
  • Automate most inbox triage so staff can focus on real work
  • Improve category consistency across teams and shared inboxes
  • Handle hundreds of emails daily without extra headcount
  • Connect Outlook with your local AI model for private processing

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Microsoft Outlook and Ollama. See the Tools Required section above for links to create accounts with these services.
  3. Open any Microsoft Outlook node, then in the Credential to connect with dropdown click Create new credential. Sign in with your work account and allow Mail.ReadWrite permission. Save the credential.
  4. On the Outlook message list node, choose your Inbox folder. In the Filter field, paste: flag/flagStatus eq 'notFlagged' and not categories/any(). This skips flagged emails and messages that already have a category.
  5. Double click the Ollama Chat Model node. Set the Host to your Ollama server URL and choose the qwen2.5:14b model. Ensure the model is installed on your Ollama host. If needed, run an ollama pull command on your server.
  6. Open the AI Agent node and confirm it uses the Ollama Chat Model. Keep temperature low for stable results, or adjust if you want broader suggestions.
  7. Open the Switch node to map each AI category to the correct Outlook update and move paths. Edit labels to match your own naming.
  8. On each Outlook Update node, confirm the categories field builds from the AI output category and subCategory. On each Outlook Move node, select the target folder. Use the folder picker to avoid ID mistakes.
  9. Run the workflow using Test. Check a few emails to confirm categories and folder moves. Review the Catch Errors node output to spot any parsing issues.
  10. If you want this to run on a schedule, add a Cron node set to every 5 minutes and connect it to the start. Keep the manual trigger for testing only.
  11. Troubleshooting: If Outlook errors with permissions, reauthorize the credential with Mail.ReadWrite. If the AI step fails, confirm the Ollama host is reachable from n8n and the model name matches exactly.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Microsoft Outlook

Sign up

Exchange Online (Plan 1): $4.00 user / mo (annual billing)

Ollama

Sign up

Free tier: $0 (self-hosted local API)

Credits:
Built by Wayne Simpson at nocodecreative.io. Watch the setup video: YouTube video

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.