Skip to content

Every 15 minutes

Save email attachments to OneDrive folders

Attachments from incoming emails are filed in OneDrive by sender, with a log of every file saved.

Runs
Every 15 minutes
Apps
OneDrive, Outlook
AI
Not needed
Access
Mail.Read, Files.ReadWrite

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, save attachments from new Outlook emails into OneDrive under Email Attachments, in a folder per sender, and add a line to my log workbook.

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

Invoices, photos, signed forms and reports arrive all day as attachments. Finding last month's invoice from a supplier means scrolling through email search, and files are lost when a mailbox is cleaned out.

Filing every attachment into OneDrive by sender as it arrives gives you a folder per client or supplier that syncs to your computer and phone, with a log to check what came in and when.

What you get out of it

  • Find files by who sent them

    Each sender gets their own folder. Last month's invoice from a supplier is two clicks away.

  • Files on every device

    OneDrive syncs to your computer and phone. Attachments are available offline and in your file manager.

  • A simple log

    Each saved file is listed with sender, subject and date. You can check at a glance whether something arrived.

  • Nothing to remember

    Files are saved every 15 minutes without you opening Outlook.

How it works

What happens, step by step

  1. Every 15 minutes it looks for new emails with attachments.

  2. Inline images like logos are skipped.

  3. Each attachment is saved to a folder named after the sender in OneDrive.

  4. A row is added to your log workbook with the file name, sender and date.

  5. It remembers the newest email it handled, so nothing is saved twice.

Before it runs live

  • Connect OneDrive
  • Connect Outlook

What you get

RunsEvery 15 minutes
Save email attachments to OneDrive folderstoday, 9:00Succeeded
OneDrive · Email Attachmentsbilling@acme.example/Invoice-2291.pdf saved and logged

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 OneDrive and 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_outlook_attachments_to_onedrive.pyexample
GRAPH = "https://graph.microsoft.com/v1.0"
import base64
from clickruntime import on_trigger, credentials, http, state, report_fetched

LOG = "/me/drive/root:/Email Attachments/log.xlsx:/workbook/tables/Log/rows/add"

@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"hasAttachments eq true and receivedDateTime gt {since}",
                    "$orderby": "receivedDateTime", "$select": "id,subject,from,receivedDateTime"}).json()["value"]
    report_fetched(len(msgs))
    if not msgs:
        return {"summary": "Nothing new"}
    rows = []
    for m in msgs:
        sender = m["from"]["emailAddress"]["address"]
        for a in http.get(f"{GRAPH}/me/messages/{m['id']}/attachments", headers=h).json()["value"]:
            if a.get("isInline") or "contentBytes" not in a:
                continue
            http.put(f"{GRAPH}/me/drive/root:/Email Attachments/{sender}/{a['name']}:/content", headers=h, data=base64.b64decode(a["contentBytes"]))
            rows.append([m["receivedDateTime"][:16], sender, m["subject"], a["name"]])
    if rows:
        http.post(f"{GRAPH}{LOG}", headers=h, json={"values": rows})
    state.set("since", msgs[-1]["receivedDateTime"])
    return {"saved": len(rows)}

FAQ

Common questions

Can I only save attachments from certain senders?
Yes. You can limit it to a list of addresses or domains, such as your suppliers.
Are signature images saved?
No. Inline images are skipped and only real attachments are saved.
Where is the log kept?
In an Excel workbook in your OneDrive, with one row per saved file.
What permissions does it need?
Mail.Read, 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 “Save email attachments to OneDrive folders” from your assistant

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