Skip to content

Every 15 minutes

File Outlook attachments in OneDrive

Attachments you receive are saved to OneDrive in a folder per sender.

Runs
Every 15 minutes
Apps
Outlook
AI
Not needed
Access
read mail + write files (Files.ReadWrite)

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, save new attachments from my Outlook inbox to OneDrive under Attachments/<sender name>.

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

A bookkeeper receives receipts, bank statements and contracts as email attachments throughout the day, and each one has to be saved to the right client folder. Downloading, renaming and dragging files takes a minute or two each, and during busy periods attachments sit in the inbox for weeks. When a client asks for a particular statement, she searches her mail and hopes the sender used a sensible subject line.

Every 15 minutes, new Outlook messages with attachments are listed, each attachment is downloaded, and it is placed in a OneDrive folder path you define, for example by sender or by month. The files are then available in OneDrive, backed up and shareable, regardless of what happens to the original email.

It suits bookkeepers, recruiters collecting resumes, property managers receiving certificates and anyone whose work arrives as attachments.

What you get out of it

  • Files are in the right place when needed

    Instead of searching mail for a statement, you open the client folder and find it. The time saved on each lookup adds up over a year of busy periods. That saves effort every time a client or an auditor asks for a specific document.

  • Attachments survive inbox clean-ups

    Once files are in OneDrive, deleting or archiving the email does not lose them. You can clear your inbox without worrying about important documents. That safety net means you can keep your mailbox small and your documents safe.

  • Sharing becomes simple

    A OneDrive file can be shared by link with an accountant or a client, and you do not need to forward the original email and hope the attachment is intact.

  • Consistent folder structure

    Using the same path rules every time gives you folders organized by sender or month. A tidy structure makes audits and handovers less painful. That discipline pays off when you hand the work to a colleague or an accountant during a busy period.

  • No more manual downloading

    Saving attachments one at a time is dull, repetitive and easy to forget. Having it happen on its own gives you back minutes each day and removes a task. That also removes a recurring chore that few people enjoy and many forget.

How it works

What happens, step by step

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

  2. It downloads each attachment.

  3. It saves them to OneDrive under Attachments, in a folder named after the sender, so all files from one supplier end up together.

Before it runs live

  • Connect Outlook

What you get

RunsEvery 15 minutes
File Outlook attachments in OneDrivetoday, 9:00Succeeded
OneDrive · Attachments/billing@northwind.comINV-2291.pdf · Statement-Oct.pdf

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
  • Add an AI step, for example to summarize, sort or draft a reply
  • 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.
save_attachments_to_onedrive.pyexample
import base64
from clickruntime import on_trigger, credentials, http, state, report_fetched

GRAPH = "https://graph.microsoft.com/v1.0"

@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/messages", headers=h, params={
        "$filter": f"receivedDateTime gt {since} and hasAttachments eq true",
        "$orderby": "receivedDateTime asc", "$select": "id,from,receivedDateTime"}).json()["value"]
    report_fetched(len(msgs))
    if not msgs:
        return {"summary": "Nothing new"}
    saved = 0
    for m in msgs:
        sender = m["from"]["emailAddress"]["address"]
        for att in http.get(f"{GRAPH}/me/messages/{m['id']}/attachments", headers=h).json()["value"]:
            if att["@odata.type"] != "#microsoft.graph.fileAttachment":
                continue
            http.put(f"{GRAPH}/me/drive/root:/Attachments/{sender}/{att['name']}:/content",
                     headers={**h, "Content-Type": "application/octet-stream"}, data=base64.b64decode(att["contentBytes"]))
            saved += 1
    state.set("since", msgs[-1]["receivedDateTime"])
    return {"saved": saved}

FAQ

Common questions

Which attachments are saved?
All file attachments on new messages, or only those of types you choose, such as PDF, XLSX and DOCX. Inline images such as signature logos can be skipped so your folders are not filled with clutter.
What if two attachments have the same name?
The file name can be given a date or sender prefix, or a number, so that nothing is overwritten. You choose the naming rule, and a consistent prefix also helps sorting. Date prefixes make documents easier to sort and avoid accidental replacements.
Does it remove the attachment from the email?
No. The email and its attachment stay as they are in Outlook, and the file is copied to OneDrive. You keep both, and you can clean up the inbox later at your own pace. Keeping both copies is the safest default, and cleaning up is entirely your decision.
What permissions does it need?
read mail + write files (Files.ReadWrite). Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's 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 “File Outlook attachments in OneDrive” from your assistant

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