Hourly Outlook attachment archiver to Google Drive

By General Input

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

Integrations

  • Microsoft Outlook
  • Google Drive
  • Google Sheets

Type

Deterministic Code

Categories

  • Operations
  • Personal Productivity

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.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentLocal listing health board for every location you manageLet support send one-off Loops emails without an engineerStop cold emails to anyone with a live deal in PipedriveiMessage campaign console with pre-flight checks and delivery boardLinkedIn Ads budget pacing dashboard for every client accountFront desk appointment confirmation board for the next 3 daysGive your team Looker numbers without buying more seatsBuild audience segments from product usage and push to LoopsTurn the people who engage with your posts into Pipedrive leads