If you regularly receive reports, invoices, or updates in Outlook from the same sender and each email comes with an attachment you know how tedious it can be to manually save those files every single time.
I had the exact same problem. Every week, automated emails landed in my inbox with attachments I needed to save for later. Instead of continuing to do this manually, I decided to automate it using PowerShell.
This guide walks you through the script I created to automatically find emails from a specific sender and save their attachments into a folder on your computer. It’s a quick, reliable way to handle repetitive Outlook tasks and keep your files organized without lifting a finger.
What This Script Does
This PowerShell script uses the Outlook COM object to connect to your Outlook inbox and automatically download attachments from emails that meet specific criteria in this case, the sender’s email address.
Here’s what happens step by step:
- Connects to Outlook – The script communicates directly with your local Outlook application (so Outlook must be open when you run it).
- Searches your Inbox – It loops through each email in your Inbox folder.
- Filters by sender – It checks whether the message was sent from the email address you specify.
- Finds attachments – It only processes emails that actually include attachments.
- Saves attachments locally – Each attachment is downloaded to a folder you define on your computer.
- Adds timestamps – Filenames include the email’s received date, preventing overwrites and helping with organization.
- Creates folders automatically – If the destination folder doesn’t exist, the script will create it for you.
Why This Is Useful
This automation can save you a lot of time if you:
- Receive recurring automated reports (e.g. weekly updates)
- Need to store attachments from a specific supplier or system
- Manage regular emails from monitoring or alert tools
- Want a reliable archive of attachments for compliance or tracking
Instead of spending time each week downloading and sorting attachments, this PowerShell script does it for you instantly.
How It Works in Detail
- You define two variables:
$Sender– the specific email address to watch for$SavePath– the folder where attachments should be saved
- The script checks if the folder exists — and creates it if not.
- It then loops through every email in your Inbox, and for each message:
- If it’s from the defined sender
- And has one or more attachments
- It saves those attachments into the folder with a timestamped filename
- The script outputs status messages as it processes emails, so you can see what’s being saved and where.
Things to Know Before You Run It
- Outlook must already be open. PowerShell uses Outlook’s COM API to access your mailbox.
- This script works on Windows systems with Outlook installed.
- It only processes the Inbox (though it can be easily modified for other folders).
- You can safely schedule it with Windows Task Scheduler for automatic runs (e.g., daily or weekly).
The PowerShell Script
Here’s the complete script you can use.
Simply update the $Sender and $SavePath variables to match your setup.
# Ensure Outlook is open before running this script
# Create Outlook COM object
$Outlook = New-Object -ComObject Outlook.Application
$Namespace = $Outlook.GetNamespace("MAPI")
$Inbox = $Namespace.GetDefaultFolder(6) # 6 = Inbox
# Define sender and save path
$Sender = "noreply@example.com"
$SavePath = "C:\Users\YourName\Documents\Saved_Attachments"
# Create folder if it doesn't exist
if (!(Test-Path -Path $SavePath)) {
New-Item -ItemType Directory -Path $SavePath
}
Write-Host "Scanning inbox for emails from $Sender..."
# Loop through inbox items
foreach ($Item in $Inbox.Items) {
if ($Item -is [Microsoft.Office.Interop.Outlook.MailItem]) {
try {
$Mail = $Item
if ($Mail.SenderEmailAddress -eq $Sender -and $Mail.Attachments.Count -gt 0) {
$ReceivedDate = $Mail.ReceivedTime.ToString("yyyy-MM-dd_HH-mm")
Write-Host "Found email: $($Mail.Subject) received on $ReceivedDate"
foreach ($Attachment in $Mail.Attachments) {
$SafeFileName = "$ReceivedDate`_$($Attachment.FileName)"
$FilePath = Join-Path $SavePath $SafeFileName
$Attachment.SaveAsFile($FilePath)
Write-Host "Saved: $SafeFileName"
}
}
} catch {
Write-Host "Error processing email: $($_.Exception.Message)"
}
}
}
Write-Host "Done scanning inbox."
Final Thoughts
This small automation has made a huge difference in how I manage routine emails.
Instead of manually saving attachments each week, I simply run this PowerShell script and it handles everything in seconds.
Whether you’re managing reports, invoices, or alerts, this approach helps you:
- Save time
- Stay organized
- Reduce manual errors
Give it a try, and you’ll see how easily PowerShell can turn a repetitive Outlook task into a one click solution.
