Lorixen.
EN

Save Email Attachments Into the Right Client Folder Automatically

Short answer: Filter incoming mail with labels, look up the sender in a simple table to find the client folder, and save each attachment under a fixed naming pattern. Anything the lookup cannot match goes to a review folder that a person empties each morning. Handle duplicates by comparing file names and sizes before saving, and do not automate documents that carry sensitive identifiers. A tidy setup takes a few hours to build and then runs with a short check each week.

Start with a sender table

The heart of the automation is a list that maps each sender address to a client folder. Keep it in a spreadsheet with three columns: the sender's email address, the client code, and the folder ID or path in Drive or Dropbox. A client with two contacts gets two rows pointing to the same folder. Your team updates the table when a new client arrives, which is a deliberate step, because guessing folders from names is where misfiled documents come from.

For example, a bookkeeping firm might list "owner@example-bakery.ca" against client code BAK-014, with the folder "Clients / BAK-014 Example Bakery / 2026". The example domain is made up, but the structure is the one to copy.

Use labels as the first filter

In Gmail, create a filter for each stream of mail that carries documents, such as "invoices", "signed forms" or "receipts". The filter applies a label and skips the inbox, so the automation only reads mail you have chosen to file. Filters that match every message with an attachment will catch newsletters and signatures, which wastes time and fills the folders with noise.

A script or an automation tool then reads each labelled message, finds the attachments, and checks the sender against the table.

Name files with a template

A naming scheme keeps folders sortable without anyone thinking about it. A simple template works for most offices:

YYYY-MM-DD_CLIENTCODE_DOCTYPE_originalname.pdf

So a signed engagement letter received on 14 March 2026 from BAK-014 would be saved as 2026-03-14_BAK-014_ENGAGEMENT_signed-letter.pdf. The date comes first so that a folder sorts in time order. The document type is a short code from a fixed list, such as INV, RCPT, FORM or CORR. Keep the list short, or people will invent their own codes.

Do not rely on the sender's file name alone. Many scanners and phones produce names such as "scan0001.pdf", which tell you nothing later.

Build the unmatched folder

Every automation needs a place for the things it cannot file. Create a folder called "_Review" at the top level of your shared drive. When the sender is not in the table, when the lookup finds two possible folders, or when a file type is unexpected, the attachment lands there, and the message gets a label such as "needs filing". Someone checks the review folder each morning. The rule is that nothing is guessed, and nothing is lost.

Handle duplicates

Duplicates arise when a client resends a document, when two people forward the same email, or when a script runs twice. Before saving, check whether a file with the same client code, document type and size already exists in the destination. If it does, skip the save and add a note to the message. For critical documents, store a hash of the file contents instead of relying on size, because two different documents can share a size but two copies of the same document always match.

Keep the skipped messages in a log, so you can confirm later that nothing was dropped.

What not to automate

Some documents should stay in a controlled process. Do not automate filing of passports, driving licences, social insurance numbers, bank account details, health records or any document that holds a full card number. Do not put those identifiers into file names, because file names appear in notifications, sync logs and shared links. If your clients send such documents, route them to a secured area with limited access, and keep the automation for ordinary documents.

Test with a dummy client

Create a test client and a test folder, send yourself three messages, and check each result. Test one correctly matched message, one from an unknown sender and one that is a duplicate. Look at the file name, the folder, the label and the review queue in each case. Only then point the automation at real folders.

Weekly check

Once a week, open the review folder, the duplicate log and the file names from the previous seven days. Fix any patterns, such as a client who uses two sender addresses, by adding a row to the table. The whole check takes about fifteen minutes and keeps the system reliable without much attention.

Keep the sender table honest

Once a quarter, sort the sender table by the number of files filed against each row. Rows that have never received a file may be out of date. A client who has left should be marked inactive rather than deleted, so historical filings still resolve. Also check that no row points to a folder that has been renamed or moved, because a broken link sends every new file to the review folder without an obvious error.

FAQ

Do I need a paid automation tool?

Not necessarily. A short script with Apps Script can read Gmail labels and save files to Drive. A paid tool is easier to maintain if your team does not write code.

What if a client changes email address?

Add the new address to the table with the same client code. Keep the old row for a while, so older threads still file correctly.

Can the automation rename files that people already saved?

It can, but only with a careful script that logs every change. Test on a copy of the folder first, because a renamed file breaks links that people may have shared.

Who should own the table?

One named person. Shared ownership usually means that nobody updates it, and new clients end up in the review folder for months.

If the filing rules are tricky for your office, tell us how your client documents arrive and our studio will design a setup that fits your folders and keeps sensitive files out of the automation.

Sources

WhatsAppBook a call