Skip to content

Every 15 minutes

Archive email attachments to a SharePoint library

Attachments from incoming emails are saved to your SharePoint library by date, with a log of what was filed.

Runs
Every 15 minutes
Apps
Outlook, SharePoint
AI
Not needed
Access
Mail.Read, Sites.ReadWrite.All

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, save attachments from new Outlook emails into the Inbox Files library in SharePoint, in a folder per month, and add a row to the Attachment Log list.

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

Contracts, purchase orders and signed forms arrive as email attachments and stay there, in one person's mailbox. When that person is off or leaves, nobody else can find the file, and auditors want documents kept somewhere official.

Filing every attachment into a SharePoint library as it arrives puts the documents where the whole team, and your retention policies, can reach them, with a log showing who sent each file and when.

What you get out of it

  • Files the whole team can find

    Documents live in SharePoint instead of one inbox. Anyone with access can search for them.

  • Covered by your retention rules

    SharePoint libraries carry your organisation's retention and backup policies. Email attachments in personal mailboxes often don't.

  • A clear trail

    Each saved file is logged with sender, subject and date. That answers 'when did we receive this?' quickly.

  • No manual saving

    Nobody has to drag files out of Outlook. It happens every 15 minutes, including when you're away.

How it works

What happens, step by step

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

  2. Inline images like signature logos are skipped.

  3. Each attachment is saved into a monthly folder in your SharePoint library.

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

  5. It remembers the newest email it handled, so files aren't saved twice.

Before it runs live

  • Connect Outlook
  • Connect SharePoint

What you get

RunsEvery 15 minutes
Archive email attachments to a SharePoint librarytoday, 9:00Succeeded
SharePoint · Inbox Files2026-10/PO-4471-Northwind.pdf saved from purchasing@northwind.example

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 and SharePoint 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.
archive_outlook_attachments_to_sharepoint.pyexample
GRAPH = "https://graph.microsoft.com/v1.0"
SITE = "contoso.sharepoint.com:/sites/operations:"
import base64
from clickruntime import on_trigger, credentials, http, state, report_fetched

@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"}
    saved = 0
    for m in msgs:
        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
            path = f"{m['receivedDateTime'][:7]}/{a['name']}"
            http.put(f"{GRAPH}/sites/{SITE}/drive/root:/Inbox Files/{path}:/content", headers=h, data=base64.b64decode(a["contentBytes"]))
            log = {"fields": {"Title": a["name"], "Sender": m["from"]["emailAddress"]["address"], "Subject": m["subject"]}}
            http.post(f"{GRAPH}/sites/{SITE}/lists/Attachment Log/items", headers=h, json=log)
            saved += 1
    state.set("since", msgs[-1]["receivedDateTime"])
    return {"saved": saved}

FAQ

Common questions

Are inline images and signatures saved too?
No. Inline images, such as logos in email signatures, are skipped. Only real attachments are filed.
How are files organised?
Into a folder for each month by default. You can organise by sender instead.
What if two files have the same name?
The newer file is saved with a short suffix, so nothing is overwritten.
What permissions does it need?
Mail.Read, Sites.ReadWrite.All. 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 “Archive email attachments to a SharePoint library” from your assistant

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