Hourly Outlook attachment archiver to Google Drive

Run every hour to pull new Outlook attachments, file them into dated Google Drive folders, and log every file to a Google Sheets tracker.

Deterministic Code
Microsoft OutlookGoogle DriveGoogle SheetsOperationsPersonal ProductivityDocument ProcessingData SyncEmail Automation

Build me a deterministic code workflow that archives Microsoft Outlook attachments to Google Drive on an hourly cron schedule. The flow should be predictable CRUD steps, no agent loop.

Trigger: cron, every hour. Track the last run timestamp in workflow state so each run only processes messages newer than the previous run.

Step 1, on Microsoft Outlook, call List Messages with a receivedDateTime filter greater than the last run timestamp and hasAttachments=true. Optionally accept a configured Outlook folder ID (for example my Invoices or Contracts folder) and scope the list to that folder. Page through all results.

Step 2, for each message, call List Attachments on Microsoft Outlook. Filter to file attachments only (skip item attachments and inline images unless explicitly enabled). For each file attachment, call Get Attachment to retrieve the contentBytes.

Step 3, on Google Drive, build a dated folder path using the message receivedDateTime and the sender's email domain. Default layout: /YYYY/MM/sender-domain/. Use Create Folder for any segment of the path that does not already exist, reusing existing folders by ID when they do.

Step 4, upload each attachment into the resolved folder. If the file size is under 5MB, use Upload File (Multipart). If it is 5MB or larger, use Upload File (Resumable). Capture the resulting Drive file ID and webViewLink.

Step 5, on Google Sheets, call Append Values on a configured spreadsheet and tab to log one row per archived attachment with these columns: received date, sender email, subject, filename, file size in bytes, Google Drive file URL, Outlook message web URL, and Outlook message ID.

Dedupe rule: before uploading, check the tracker sheet for the Outlook message ID. If the message ID is already present, skip the entire message so reruns and overlapping time windows never double-archive.

Inputs I should be able to configure: Outlook folder ID (optional, default = entire inbox), Google Drive parent folder ID (where the YYYY/MM tree lives), Google Sheets spreadsheet ID and tab name, and an optional list of allowed file extensions.

Required scopes: Microsoft Outlook Mail.Read, Google Drive drive.file, Google Sheets spreadsheets. Handle pagination on List Messages and List Attachments, and fail the run loudly if any single attachment upload fails so I can rerun safely with the dedupe key.

Additional information

What does this prompt do?
  • Runs on a cron schedule every hour and pulls new Outlook messages with attachments since the last run.
  • Downloads each file attachment and uploads it to a dated Google Drive folder organized by year, month, and sender domain.
  • Uses multipart upload for files under 5MB and resumable upload for larger files automatically.
  • Appends a row to a Google Sheets tracker with received date, sender, subject, filename, size, Drive URL, and Outlook message URL.
  • Dedupes by Outlook message ID so reruns never double-archive the same attachment.
What do I need to use this?
  • A Microsoft Outlook account with Mail.Read scope (and access to the folder you want to scope, like Invoices or Contracts).
  • A Google Drive account with the drive.file scope so the workflow can create folders and upload files it owns.
  • A Google Sheets spreadsheet with a header row for the tracker (received date, sender, subject, filename, size, Drive URL, Outlook URL) and the spreadsheets scope.
  • Optional: the Outlook folder ID or label you want to limit archiving to.
How can I customize it?
  • Change the cron cadence from hourly to every 15 minutes, daily, or any schedule that matches your inbox volume.
  • Swap the folder structure (default is /YYYY/MM/sender-domain/) for /client-name/, /YYYY-Q#/, or a flat folder if you prefer.
  • Restrict the source to a specific Outlook folder or label (Invoices, Contracts, Receipts) by passing its folder ID into List Messages.
  • Add filename or MIME-type filters so only PDFs, images, or specific extensions get archived.
  • Point the tracker at a different Google Sheet or add columns like contract value, due date, or a manual review checkbox.

Frequently asked questions

How does the workflow avoid archiving the same attachment twice?
It uses each Outlook message ID as the dedupe key. Before uploading, it checks the Google Sheets tracker for that message ID and skips any message already logged, so reruns and overlapping windows are safe.
What happens with attachments larger than 5MB?
The workflow automatically switches from Upload File (Multipart) to Upload File (Resumable) for files over 5MB, which streams the file to Google Drive in chunks and is the recommended path for large attachments.
Can I scope it to just one folder, like Invoices?
Yes. List Messages accepts a folder ID, so you can point the workflow at a specific Outlook folder or label and ignore the rest of your mailbox.
Where do the files end up in Google Drive?
By default, files are filed under /YYYY/MM/sender-domain/ and the workflow uses Create Folder to build any missing folders on the fly. You can change this layout in the prompt before generating the workflow.
Why use a code workflow instead of an agent?
Every step here is deterministic CRUD: list messages, list attachments, download, upload, append. A code workflow gives you predictable execution, easier debugging, and lower per-run cost than an agent loop.

Stop hand-saving Outlook attachments into Drive.

Connect Outlook, Google Drive, and Google Sheets once, and Geni archives every new attachment every hour, with a full audit trail in your tracker.