Skip to main content

Archive Outlook email attachments to OneDrive with SharePoint logging

Workflow preview

Workflow preview
100%
Archive Outlook email attachments to OneDrive with SharePoint logging preview
Open on n8n.io

1. Workflow Overview

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, an...

Best for

  • File Management automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.scheduletrigger, n8n-nodes-base.microsoftoutlook, n8n-nodes-base.if, n8n-nodes-base.noop, n8n-nodes-base.splitinbatches, n8n-nodes-base.code, n8n-nodes-base.microsoftonedrive, n8n-nodes-base.microsoftsharepoint

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Mychel Garzon.

Original n8n.io source

1.1 Workflow description

Title
Archive Outlook email attachments to OneDrive with SharePoint logging
Workflow name
Archive Outlook email attachments to OneDrive with SharePoint logging

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

  • Automatic folder structure: No manual folder creation needed, the archive path is derived from the sender domain and received date on every run
  • 0-byte guard: Inline images and empty attachment objects are filtered out before upload, so only real files reach OneDrive
  • Audit-ready: Every processed email produces a SharePoint list record for compliance tracking, regardless of whether attachments were found
  • Batch loop: Emails are processed one at a time to avoid API throttling and keep execution predictable
  • Global error handling: A dedicated Error Trigger catches any execution failure, sends an alert email with the execution ID and failed node name, and logs upload failures separately to the SharePoint audit list

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 ([email protected])
  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

  • Operations and admin teams receiving high volumes of emailed documents, invoices, contracts, and reports. that need consistent filing
  • Finance departments archiving supplier invoices and statements automatically without manual download and upload
  • Compliance teams that need a timestamped audit trail of every document received and where it was stored
  • IT teams at SMEs replacing manual file management with a lightweight, credential-based Microsoft 365 automation

Required credentials

  • Microsoft Outlook OAuth2
  • Microsoft OneDrive OAuth2
  • Microsoft SharePoint OAuth2

Folder structure

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


How to customize it

  • Change the folder structure: Modify the path logic in the Build Folder Path + Decode Attachment node to organise by department, document type, or any other field available on the email
  • Filter by sender: Add an IF node after Get Unread Emails to only process emails from specific domains or addresses
  • Add more destinations: Fan out from Has File Attachments? to also copy files to SharePoint document libraries or Azure Blob Storage
  • Adjust the schedule: Change the trigger interval from hourly to every 15 minutes or once per day depending on your email volume
  • Extend the audit log: Add columns to the SharePoint list for file size, content type, or a generated document ID for downstream reference

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Every Hour

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 2 - Get Unread Emails with Attachments

Type / Role
n8n-nodes-base.microsoftOutlook - microsoftOutlook
Config choices
Version 2

Block 3 - Has Emails?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 4 - No Emails - Done

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 5 - Process One Email at a Time

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 6 - Get Email Attachments

Type / Role
n8n-nodes-base.microsoftOutlook - microsoftOutlook
Config choices
Version 2

Block 7 - Build Folder Path + Decode Attachment

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 8 - Upload to OneDrive

Type / Role
n8n-nodes-base.microsoftOneDrive - microsoftOneDrive
Config choices
Version 1

Block 9 - Log to SharePoint Audit List

Type / Role
n8n-nodes-base.microsoftSharePoint - microsoftSharePoint
Config choices
Version 1

Block 10 - Mark Email as Read

Type / Role
n8n-nodes-base.microsoftOutlook - microsoftOutlook
Config choices
Version 2

Block 11 - Workflow Error Trigger

Type / Role
n8n-nodes-base.errorTrigger - errorTrigger
Config choices
Version 1

Block 12 - Send Error Email

Type / Role
n8n-nodes-base.microsoftOutlook - microsoftOutlook
Config choices
Version 2

Block 13 - Is Upload Error?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 14 - Log Failed Upload to SharePoint

Type / Role
n8n-nodes-base.microsoftSharePoint - microsoftSharePoint
Config choices
Version 1

Block 15 - Has File Attachments?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 16 - Aggregate Attachment Uploads

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Archive Outlook email attachments to OneDrive with SharePoint logging
Complexity advanced
Nodes 22
Categories File Management
Author Mychel Garzon
Published 18 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15793/15793.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Archive Outlook email attachments to OneDrive with SharePoint logging do?

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, an...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your File Management use case.