Skip to content

Every 5 minutes

Sort new Outlook mail into categories

Each new email is tagged Action, Info, Newsletter or Junk, and newsletters are moved out of your way.

Runs
Every 5 minutes
Apps
Outlook
AI
Yes, uses the built-in AI allowance
Access
Mail.ReadWrite

Send this to your assistant

Create a ClickRuntime automation: every 5 minutes, sort my new Outlook emails into the categories Action, Info, Newsletter or Junk, and move anything marked Newsletter to my Reading folder.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

An operations manager receives about 150 emails a day in Outlook: supplier quotes, customer questions, invoices, internal approvals, newsletters and the occasional urgent escalation. Everything lands in one inbox, so the one message that needs an answer in the hour is buried under routine items, and sorting by hand with rules only works for senders you already know. Unread counts climb, and important mail gets answered late.

Every five minutes, new messages in the inbox are picked up, and ClickRuntime's built-in AI reads the sender, subject and body to decide what each one is about, such as Invoice, Customer question, Approval needed or Newsletter. The matching Outlook category is applied to the message, or it is moved into a folder you named, within minutes of arriving.

It is especially useful where the same inbox handles several kinds of work and rules based on sender cannot keep up.

What you get out of it

  • Urgent mail stands out

    When an escalation arrives with a red category, you notice it among the routine items. That shortens the delay between a customer's problem and your response, which protects the relationship.

  • Rules for unknown senders become unnecessary

    A rule needs a known sender or phrase, but a new supplier or a customer from another company has none. Reading what the message is about sorts it correctly on the first message.

  • Triage by category takes seconds

    Filtering the inbox by Invoice or Approval needed means you can work through one type of task at a time. Doing similar tasks in one sitting is faster than switching constantly.

  • Fewer things fall through

    Invoices and approvals that used to hide between newsletters get labeled so they are visible in the category view. That reduces late payments and forgotten sign-offs. Anything labeled Invoice can be paid on time, and anything labeled Approval needed is hard to forget.

  • A calmer inbox without manual sorting

    Spending twenty minutes a day dragging messages into folders is time you do not get back. Letting each new message arrive already labeled returns that time to real work. That time adds up to more than an hour each week, which is better spent on real replies.

How it works

What happens, step by step

  1. Every 5 minutes, ClickRuntime checks your Outlook inbox for new emails since the last check.

  2. AI reads the sender, subject and opening lines of each one and labels it Action, Info, Newsletter or Junk.

  3. Each email gets that category in Outlook, and newsletters are moved out of your inbox.

Before it runs live

  • Connect Outlook

What you get

RunsEvery 5 minutes
Sort new Outlook mail into categoriestoday, 9:00Succeeded
Outlook · InboxQ4 renewal quote from Northwind → Action Acme Weekly: 5 product updates → Newsletter (moved)

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Change what the AI looks for, or how it writes the result
  • Add another app, for example also send it to Slack
  • Combine it with other Outlook steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
ai_auto_categorise_new_mail.pyexample
from clickruntime import on_trigger, credentials, http, state, ai, report_fetched

GRAPH = "https://graph.microsoft.com/v1.0"
NEWSLETTER_FOLDER_ID = "AAMkAD...newsletters"
LABELS = ["Action", "Info", "Newsletter", "Junk"]

@on_trigger
def run(event):
    h = {"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}
    since = state.get("since") or "2026-01-01T00:00:00Z"
    msgs = http.get(f"{GRAPH}/me/mailFolders/inbox/messages", headers=h, params={
        "$filter": f"receivedDateTime gt {since}", "$orderby": "receivedDateTime asc",
        "$select": "id,subject,from,bodyPreview,receivedDateTime", "$top": 25}).json()["value"]
    report_fetched(len(msgs))
    if not msgs:
        return {"summary": "Nothing new"}
    numbered = "\n".join(f"{i}. From {m['from']['emailAddress']['address']}: {m['subject']} – {m['bodyPreview'][:200]}" for i, m in enumerate(msgs))
    labels = ai.generate(numbered, system=f"Label each numbered email as one of {LABELS}.", max_output_tokens=20 * len(msgs),
                         json_schema={"type": "object", "properties": {"labels": {"type": "array", "items": {"type": "string", "enum": LABELS}}}}).json["labels"]
    for m, label in zip(msgs, labels):
        http.patch(f"{GRAPH}/me/messages/{m['id']}", headers=h, json={"categories": [label]})
        if label == "Newsletter":
            http.post(f"{GRAPH}/me/messages/{m['id']}/move", headers=h, json={"destinationId": NEWSLETTER_FOLDER_ID})
    state.set("since", msgs[-1]["receivedDateTime"])
    return {"labelled": len(msgs)}

FAQ

Common questions

Which categories does it use?
The ones you define. Outlook categories are color-coded labels that you create, and the AI chooses among the names you provide. A short, clear list such as Invoice, Customer, Internal and Newsletter usually gives the best results.
What if the AI picks the wrong category?
Occasional misses are expected, particularly with vague or very short messages. Since the original message stays in your inbox, you can correct a label in Outlook in a few seconds, and tell your assistant to tighten the rules.
Does it read my whole mailbox?
It looks at new inbox messages from the point you set it up, and the sender, subject and message text are used to decide the category. Older mail is left alone unless you ask for a one-off catch-up.
What permissions does it need?
Mail.ReadWrite. Nothing else in your accounts is used.
Does it need AI?
Yes. It uses ClickRuntime's built-in AI, so you don't need an OpenAI or Anthropic key. Every plan includes a monthly AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Sort new Outlook mail into categories” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.