Automatic Email Categorization and Organization with Outlook and GPT-4o
n8n – Outlook AI Categorization & Labeling (Fully Automated)
> Zero manual mapping. The workflow automatically discovers your Outlook folders, understands the context, assigns the correct category, and moves the email into the right folder. It uses the original Microsoft Outlook nodes plus an AI Agent. You can connect OpenAI or any other LLM provider.
✨ Features
Self-Discovery:** Scans your Outlook folders automatically – no manual mapping required. AI-Powered Decisions:** Considers sender, subject, content, links, attachments, timing, and business context. Label + Move:** Assigns the right Outlook category and moves the email into the correct folder. Dual Category Logic:** Can apply both a primary and a secondary category (e.g., Action + Project). Error Handling:** Captures errors and continues without breaking the workflow. Flexible AI Backend:** Replace OpenAI with your own LLM if preferred.
🚀 Setup (5 Steps)
Connect Outlook
In n8n → Credentials → Microsoft Outlook, grant at least Mail.ReadWrite.
Connect AI
In n8n → Credentials, set up OpenAI (or another model). Works best with GPT-4.x or GPT-4o.
Import the Workflow
n8n → Workflows → Import from File/Clipboard and paste the provided JSON.
Enable Trigger
Adjust the Schedule Trigger (e.g., every 5 minutes).
Run & Verify
Test run and watch emails get categorized and moved automatically.
🧠 How It Works
Schedule Trigger pulls new emails
Loop Over Items processes them one by one
Markdown / varEmail cleans the content
Get Many Folders fetches Outlook categories and folders
Summarize + Code prepare category IDs
AI Agent applies deep categorization logic
Update Category applies the Outlook category
Move Folder places the email in the right folder
Error Handling ensures workflow stability
🧩 System Prompt Example
You are an advanced AI email categorization system. Your mission is to intelligently analyze and categorize emails with maximum accuracy and context awareness.
INTELLIGENT CATEGORIZATION ENGINE:
Parse all available categories: {{ $json.category }} Multi-layer analysis: Sender, Subject, Body, Links, Attachments Prioritize: Security threats, Action Required, Business Context Specialized: SaaS, Hosting, E-commerce, Finance, Support, Corporate Anti-Spam: Pattern detection, spoofing, red-flag subjects Dual Logic: Primary + Secondary categories when applicable
OUTPUT FORMAT (JSON only): { "subject": "EXACT_EMAIL_SUBJECT", "category": "PRIMARY_CATEGORY_FROM_AVAILABLE_LIST", "subCategory": "SECONDARY_CATEGORY_IF_APPLICABLE", "analysis": "Reasoning", "confidence": "HIGH/MEDIUM/LOW" }
Available Categories: {{ $json.category }}
⚙️ Parameters & Notes
Uses only existing Outlook categories (never invents new ones).
Works with any LLM that supports Chat Completions.
Requires Mail.ReadWrite permissions.
Safe fallback: if unsure, it uses the Action category.
🛡️ Security
Processes only what is needed for classification.
No external logging of email content unless you configure it.
AI provider can be swapped for self-hosted LLMs for compliance.
📄 License & Sharing
License:** MIT (or your choice).
Tags:** n8n, Outlook, Email, AI, Automation, Categorization
Import Method:** Copy/paste workflow JSON into n8n.
✅ Summary
Connect → Import → Run.
No manual mapping. AI-powered categorization that labels and organizes your Outlook mailbox automatically.
Related Templates
Use OpenRouter in n8n versions <1.78
What it is: In version 1.78, n8n introduced a dedicated node to use the OpenRouter service, which lets you to use a lot...
Task Deadline Reminders with Google Sheets, ChatGPT, and Gmail
Intro This template is for project managers, team leads, or anyone who wants to automatically remind teammates of tasks ...
🤖 Build Resilient AI Workflows with Automatic GPT and Gemini Failover Chain
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. How it works This...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments