πŸ“ Archive Outlook email attachments to OneDrive with SharePoint logging

⚑ 261 views Β· πŸ“ File Management

Description

Stop letting email attachments pile up in your inbox. Let automation file every document the moment it arrives.

Manually downloading and organising email attachments is repetitive, inconsistent, and easy to forget. This workflow checks your Outlook inbox every hour, extracts every valid attachment, uploads it to OneDrive in a structured folder hierarchy, logs the archive record to SharePoint, and marks the email as read, with zero manual intervention.


How it works

The workflow runs in five sequential stages:

1. Ingestion Checks Outlook every hour for unread emails. If the inbox is empty, the workflow exits cleanly with no further execution. If emails are found, they are queued for processing.

2. Per-Email Processing Emails are split and processed one at a time using a batch loop. For each email, all attachments are fetched from Outlook, 0-byte items are dropped, binary data is decoded, and a structured OneDrive folder path is computed automatically from the sender’s domain and the email’s received date: /Archives/{year}/{month}/{sender-domain}/

3. Upload & Aggregation Emails with valid file attachments are uploaded to OneDrive into the computed folder path. Emails with no real attachments skip the upload step entirely and go directly to aggregation. Results are collected into a summary item containing the sender, file names, upload count, and folder path.

4. Audit Logging The upload summary is appended to a SharePoint list as a compliance audit record. Every archived email produces one row with full traceability, sender address, file names, destination folder, and timestamp.

5. Completion The email is marked as read in Outlook and tagged with the Archived category. The batch loop then moves to the next email until all emails in the current run are processed.


Key benefits


Setup

  1. Microsoft Outlook: Connect your Outlook OAuth2 credential to the Get Unread Emails, Get Email Attachments, Mark Email as Read, and Send Error Email nodes
  2. Microsoft OneDrive: Connect your OneDrive OAuth2 credential to the Upload to OneDrive node and set your target drive ID and folder path expression to {{ $json.folderPath }}
  3. Microsoft SharePoint: Connect your SharePoint OAuth2 credential to the Log to SharePoint Audit List and Log Failed Upload to SharePoint nodes, and set your Site ID and List ID
  4. Error email: Update the recipient address in the Send Error Email node (it-admin@company.fi)
  5. Activate: Turn the workflow on and run it manually once to verify the folder structure is created correctly in OneDrive

Who this is for


Required credentials


Folder structure

Attachments are organized automatically: /Archives/{year}/{month}/{sender-domain}/filename.ext


How to customize it

πŸ”— Nodes Used

Microsoft OneDrive, Microsoft Outlook, Schedule Trigger, Microsoft SharePoint

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup