Skip to content
itsorted.online
Automation guide

Save Email Attachments to Drive or SharePoint Automatically

Supplier invoices, delivery orders and statements arrive as email attachments, and someone downloads and files them by hand. Microsoft 365 and Google Workspace can both do this automatically: when an email from a supplier arrives, the PDF lands in the right folder with a sensible name. This guide shows the two common set-ups, Power Automate for Outlook to OneDrive or SharePoint and Apps Script for Gmail to Google Drive, plus naming rules, duplicate handling, the limits that trip flows up, malicious attachment risks and when a receipt-capture tool is the better choice.

By IT Sorted teamReviewed 7 min readHow we write guides
in

Key takeaways

  • Power Automate's Outlook trigger can filter to emails with attachments and save each file to OneDrive or SharePoint.
  • Microsoft says the Outlook trigger may run twice when Defender Safe Attachments uses Dynamic Delivery.
  • Apps Script runs up to 6 minutes per execution and 90 minutes of triggers a day on consumer Gmail, 6 hours on Workspace.
  • Name files by date, supplier and invoice number, and check for duplicates before saving.
  • Saving a file does not make it safe: keep attachment scanning on and never auto-open saved files.
In this guide · 8 sections
  1. 01Which method fits your email system
  2. 02Outlook to OneDrive or SharePoint with Power Automate
  3. 03Gmail to Google Drive with Apps Script
  4. 04Naming rules, folders and duplicates
  5. 05Security: malicious attachments and access
  6. 06When a receipt-capture tool is the better choice
  7. 07Do it yourself or get help?
  8. 08Frequently asked questions

Short answer

In Microsoft 365, build a Power Automate flow: when a new email with attachments arrives in a folder, create each attachment as a file in OneDrive or SharePoint. In Google Workspace, an Apps Script on a timer saves attachments from labelled Gmail threads to a Drive folder. Filter by sender and file type.

Which method fits your email system

Use the tool that already comes with your email. Both are included in business plans and need no extra subscription for this job.

Microsoft 365 (Outlook)Google Workspace (Gmail)
ToolPower Automate cloud flowGoogle Apps Script
Saves toOneDrive or a SharePoint document libraryA Google Drive or shared drive folder
How it startsInstantly, when a new email arrivesOn a timer, for example every 15 minutes
Skill neededPoint-and-click designerA short script, copied and adjusted
LicenceStandard connectors are included with Microsoft 365 business plansIncluded with Google Workspace and Gmail

Microsoft's licensing documentation says Microsoft 365 licences include a limited set of Power Automate capabilities, and standard connectors such as Outlook and OneDrive are among them. Google's Apps Script is available to every Gmail and Workspace account.

Outlook to OneDrive or SharePoint with Power Automate

Start by sending supplier invoices to one place: a shared mailbox such as accounts@, or an Outlook rule that moves them to an Invoices folder. Then build the flow on that folder.

  1. Create an automated cloud flow

    In Power Automate, choose Create, then Automated cloud flow, and pick the Office 365 Outlook trigger When a new email arrives (V3).

  2. Point it at the right folder and filter

    Choose the Invoices folder or the shared mailbox, set Only with Attachments to Yes and add sender or subject filters if needed.

  3. Loop through the attachments

    Add an Apply to each over the attachments, with a condition that skips inline images and keeps only PDF or Excel files.

  4. Create the file

    Use OneDrive for Business Create file, or SharePoint Create file, with a folder such as /Accounts/Invoices/2026-10 and a name built from the date and sender.

  5. Test with real emails

    Send three test invoices, including one with two attachments and one with a logo image in the signature, and check the folder.

Gmail to Google Drive with Apps Script

Gmail has no built-in save-to-Drive rule, but a short Apps Script does the job. The usual pattern uses Gmail labels to track what has been processed.

  1. Create two labels and a filter

    Make labels such as Invoices/To file and Invoices/Filed. Add a Gmail filter that applies To file to emails from your suppliers or with invoice in the subject and an attachment.

  2. Create the script

    At script.google.com, create a project. The script searches for threads labelled To file, saves each PDF attachment to a Drive folder with DriveApp, then swaps the label to Filed.

  3. Add a time-driven trigger

    In Triggers, run the function every 15 or 30 minutes. Apps Script cannot start instantly on a new email, so a short delay is normal.

  4. Authorise and test

    Run it once by hand, approve the Gmail and Drive permissions, then send a test invoice and wait for the next run.

Google's quota page sets limits that matter here: each run can last up to 6 minutes, and time-driven triggers can run for 90 minutes a day in total on consumer Gmail accounts or 6 hours a day on Google Workspace. Process a limited batch of threads per run so a busy morning does not hit the limit. Our Apps Script automation guide covers the basics of scripts and triggers.

Naming rules, folders and duplicates

Automatic saving is only useful if people can find files later. Decide the rules before you build.

  • Folder by month or financial year: /Accounts/Invoices/2026/10 keeps folders small and matches how your accountant works.
  • File name pattern: date received, supplier, then the original file name, for example 2026-10-19_SupplierName_INV-1042.pdf.
  • Supplier name from the sender: map known sender addresses to short supplier names; put unknown senders in an Unsorted folder.
  • Duplicates: suppliers resend invoices. Check whether a file with the same name exists and skip it or add a suffix, rather than overwriting.
  • Keep the email: add a link or the email subject in the file description, or keep the email in a Filed label or folder, for audit.

Security: malicious attachments and access

Attackers send fake invoices with harmful attachments precisely because finance staff open them. An automation that saves every attachment can spread a malicious file into a shared folder where more people open it.

Before you switch the automation on

Fake invoices are also a common route for payment fraud. An automation should file documents, never approve or pay them.

When a receipt-capture tool is the better choice

If the goal is getting bills into Xero or QuickBooks, a receipt-capture service may beat a home-made flow. Tools like Dext and Hubdoc give you a dedicated email address, read the supplier, date, amount and GST from each document and publish it to your accounting software.

A Drive or SharePoint flow suits you if

  • You mainly need documents filed and findable
  • You want no extra subscription
  • Attachments include contracts, DOs and statements, not just bills

A receipt-capture tool suits you if

  • Bills must end up in Xero or QuickBooks
  • You want amounts and GST extracted automatically
  • Your accountant already uses one

Our Dext vs Hubdoc comparison covers prices and differences for Singapore businesses.

Do it yourself or get help?

A simple version, one folder and one supplier filter, is a good first DIY project in either Power Automate or Apps Script. Handling double triggers, duplicates, naming maps and safe file types takes longer to get right.

Our Workflow Automation (S$390 per workflow) builds one workflow of up to 5 steps on Make, Zapier or Google Apps Script in your own account, with error alerts to your email and documentation of how it works. Make and Zapier also connect to Outlook, OneDrive and SharePoint.

Frequently asked questions

Not with a basic Outlook rule, but Power Automate can. Use the Office 365 Outlook trigger When a new email arrives (V3) with Only with Attachments set to Yes, loop through the attachments and use the OneDrive for Business or SharePoint Create file action. Standard connectors are included with Microsoft 365 business plans.

Gmail filters cannot save to Drive on their own, but a Google Apps Script can. Label incoming invoices with a filter, and run a script every 15 or 30 minutes that saves attachments from labelled threads to a Drive folder and relabels them. Each run can last up to six minutes under Google's quotas.

Microsoft documents that when Defender for Office 365 Safe Attachments uses Dynamic Delivery, the Outlook trigger may fire twice, the first time with an empty attachments list. Add a condition after the trigger that continues only when the number of attachments is greater than zero, and check for existing files before saving.

It is reasonably safe if you limit it to known senders and safe file types such as PDF, keep attachment scanning on, and save into a folder only finance staff can open. Avoid saving zip, executable, HTML or macro-enabled files, and never let an automation approve or pay invoices.

If the main goal is getting supplier bills into Xero or QuickBooks with amounts and GST read automatically, a receipt-capture tool is usually better than a filing flow. If you mainly want documents stored and findable, including contracts and delivery orders, a Drive or SharePoint flow is simpler and needs no extra subscription.

Rather have it done for you?

Fixed price, set up in your own accounts.

Order online, get a written scope, and keep full ownership of everything we set up. Questions first? Ask us in writing.