This script automates saving email attachments. It scans for emails from a list of senders, renames attachments with a timestamp prefix (e.g., "[2025-06-19 00:16] - "), and saves them to a Shared Drive.
To prevent creating duplicate files, the script logs the unique Message ID of each processed email and skips any ID it has already processed.
The "Log" sheet is organized with a permanent header row and separate columns for: the timestamp of when the script ran, the date the email was received, a description, a link to the saved file, the message ID, a link to the email thread, the permanent ID of the saved file, and the file size.
Start by doing a copy of this sheet
In the Settings sheet:
Column A (starting from cell A2): Enter the email addresses (e.g., sender@example.com) or domains (e.g., @example.com) you want to monitor. Each entry must be in a new row.
Cell B2: Paste the Folder ID of the destination folder located in your Shared Drive.
You can automate the script by adding a time based trigger in the trigger section of the code.
The script will only work on shared drives you are a member of.