Save Outlook Attachments to Disk

There are a number of cool easy to use plugins for Outlook that facilitate transfer of attachments out of emails automatically. Lets say you have a folder called “D:\SCRALADFolder” … and you want all the email attachments dumped in there – so in essence, an automated data feed.

You can go and download, try and purchase one of these Outlook add-ins … or …  

a DIY approach … you can add a module inside Outlook to strip out your attachments, then create a rule to execute this module.  Yes you have to write some code, but read on, its easy and can be done in a few minutes.

If you don’t know where to access your development environment in Outlook, try Alt+F11 or enable the Developer tab and click the Visual Basic button in the ribbon (see here)..

After you have pasted the code below into your Visual basic module, create a rule and as a suggestion you could include the following options in your rule.
1. Apply this rule after the message arrives
2. Through the specified email account
3. Which has an attachment
4. Run a script (the module below)

saveAttachmenttoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
SCRALADFolder = "D:\YourSCRALADFolder"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile SCRALADFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing Next
End Sub

This will save the attachment as it is named in the email.  If you want to tack a datestamp on the filename you can format a datetime string then append it to the filename here in this line….

objAtt.SaveAsFile SCRALADFolder & "\" & saveDate & "_" & objAtt.DisplayName

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s