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.
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
Every 15 minutes it looks for new emails with attachments.
Inline images like logos are skipped.
Each attachment is saved to a folder named after the sender in OneDrive.
A row is added to your log workbook with the file name, sender and date.
It remembers the newest email it handled, so nothing is saved twice.
Before it runs live
- Connect OneDrive
- Connect Outlook
What you get
Build your own
Need it to work differently?
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
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?
Are signature images saved?
Where is the log kept?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Log feedback in Excel on OneDrive and get an email
Each feedback submission becomes a row in your Excel workbook and you get an email with what was said.
See how it worksBack up a daily export to OneDrive and email the result
Every night an export is saved to a dated OneDrive folder, old copies are cleared out, and you get an email saying it worked.
See how it worksSave a monthly KPI report to OneDrive and email the link
On the 1st of each month a report with last month's numbers and a short commentary is saved to OneDrive and the link is emailed to your team.
See how it worksKeep exploring
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.