Saving Multiple Attachments in Outlook

Saving a single email attachment is pretty easy: you just open the email, right-click on the attachment, select “Save”, pick a location for the file and then click OK. However, this process can be quite tedious when one has an entire folder full of attachments, which might happen if you’re part of an HR department that gets hundreds of résumés via email a day.

I ran into this problem myself just the other day – I subscribed to a new podcast using NewsGator, which integrates RSS feeds and podcasts into Outlook. Because I had never downloaded anything from this particular podcast site before, NewsGator downloaded all of the show’s previous episodes… so I suddenly had 20 emails in a folder, each with a 12-20MB MP3 attached to it. I just wasn’t in the mood to save them manually, so I went on the web to see if I could find help.

What I found were tons of sites offering “Outlook plug-ins” that would do what I wanted… for $19-$49. But I didn’t want to go that route; adding yet another Outlook plug-in meant that Outlook would take even longer to open than it already does on my system, and I don’t want Outlook constantly using RAM for something I’ll only use once in a blue moon. And since I’m cheap, I really didn’t want to pay money for a plug-in either!

So my solution was a macro. In Microsoft Office, macros are powerful tools that use Visual Basic scripts to automate many processes. There are literally thousands of macros available online, and I was lucky enough to find this one (2kb, zipped). It’s quite easy to set up and use, so if you ever find yourself needing to save attachments from a bunch of emails, you should seriously check this out.

Note: this macro works in Outlook 2000 or higher. Complete instructions are included in the zip’s README.TXT file.

UPDATE #1: A jimcofer.com reader pointed out that you can save multiple attachments within a single email by selecting the message and choosing File > Save Attachments in the main Outlook window. He’s right, but that’s not the problem that this macro solves. My macro is for saving one (or more) attachments from multiple emails within the same folder. I’m not talking about saving 22 attachments from 1 email, I’m talking about saving 1 attachment each from 22 different emails – such as might happen with an HR department’s “résumé mailbox”.

UPDATE #2: One additional tip for ya… If you look at line 11 of the macro, you’ll see the following:

myOrt = InputBox(“Destination”, “Save Attachments”, “C:\”)

You can change the path contained in “C:\” to anything you’d like to set a default save location. I’ve been using this macro for months now, yet was kind of peeved that I always had to type the path to my Smartphone folder into the dialog box. So I changed that line to read:

myOrt = InputBox(“Destination”, “Save Attachments”, “G:\Smartphone Stuff\”)

My “Smartphone Stuff” folder is now the default location, so I only have to press the ENTER key to get the macro to start doing its thing. If you *do* decide to change the save location, don’t forget to add a trailing slash to your location (“C:\MP3s\”, not “C:\MP3s” )… otherwise the files will be saved in the root of the folder as “C:\MP3sfilename.mp3”.

17 Replies to “Saving Multiple Attachments in Outlook”

  1. Hi!

    I installed this macro on my CPU yesterday. The problem is that the files are extracted from the email, and I am unable to find them on my C:\. Can you help me?

    Thanks!

  2. Hello,
    I had the same problem as Jean. I put the files I wanted the attachments from into a separate folder then ran the macro. Nothing is on the drive although all the emails have the attachments gone. I modified the macro to destination C:\attachments\. The folder did not show up on C: and I cannot find the files anywhere. I have the feeling that your macro does not create folders. If this is the case, where are the files? Lost forever? Can you modify the macro to not remove the attachment after copying it to another location? I appreciate you help in trying to solve this problem.

  3. Hi Guys!

    First of all, I didn’t write this macro and don’t write macros generally. So I don’t really have the ability to edit it, although anyone is welcome to try on their own.

    I just installed the macro in Outlook 2003 on a virtual machine, and it works as expected. Bobby, the macro does not create folders, so you’d need to make sure that the folder you want to use already exists. And Jean, you need to make sure that you’ve highlighted all the emails from which you want to save the attachments – highlighting the column headers won’t work.

    I have not tested this with Outlook 2007 or Outlook 2010, so I have no idea if this macro works with them or not. So try it at your own risk.

  4. Jim ,

    Just a quick thing . I tried running it on one of my pst and was successful in saving attachment from mails to my hard drive.

    One small problem. Macro while saving is removing attachments from the mails . Am i missing on somethig ?

    Please help!

  5. @Gaurav – no, that’s by design.

    I didn’t quite make it clear in my original post, so let me explain why I needed the macro. I used to have an Exchange Server at my house. I used Outlook 2003 + NewsGator to get RSS feeds, including several podcasts.

    The problem was that the Exchange Server didn’t have a lot of free space, and NewsGator didn’t offer the option to control where to save individual feeds. I could have saved the podcasts (and all the other feeds) in a separate PST instead of the Exchange mailbox, but that wouldn’t allow me at access to rest of my feeds remotely via OWA. Because I wanted to access those feeds remotely, my only option was to save them to the mailbox.

    But many of the podcasts double or triple-posted, so it wasn’t uncommon for my mailbox to have 900MB or so of just podcasts. Rather than have my mailbox shoot up in size every day, I found the above macro, which allowed me to automatically save the attachments to a folder on my computer.

  6. Hi guys,
    I modified the script so it doesn’t change emails themselves. It puts files in C:\attachments\ (Note: don’t forget to put “\” after folder name, otherwise it doesn’t save it there)

    Sub SaveAttachments()

    ‘Declaration
    Dim myItems, myItem, myAttachments, myAttachment As Object
    Dim myOrt As String
    Dim myOlApp As New Outlook.Application
    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection

    ‘Ask for destination folder
    myOrt = InputBox(“Destination”, “Save Attachments”, “C:\attachments\”)

    On Error Resume Next

    ‘work on selected items
    Set myOlExp = myOlApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection

    ‘for all items do…
    For Each myItem In myOlSel

    ‘point on attachments
    Set myAttachments = myItem.Attachments

    ‘if there are some…
    If myAttachments.Count > 0 Then

    ‘for all attachments do…
    For i = 1 To myAttachments.Count

    ‘save them to destination
    myAttachments(i).SaveAsFile myOrt & _
    myAttachments(i).DisplayName

    Next i

    End If

    Next

    ‘free variables
    Set myItems = Nothing
    Set myItem = Nothing
    Set myAttachments = Nothing
    Set myAttachment = Nothing
    Set myOlApp = Nothing
    Set myOlExp = Nothing
    Set myOlSel = Nothing
    End Sub

  7. Jim,
    Excellent find..
    Just saved me x hours!
    (x = [1075 * n/60] where n = time in minutes to download all attachments from 1 email)

    Thanks for sharing!
    Travis.

  8. Very useful file but I have two questions based on the situation I find with some attachments.
    When a file is being modified and re-sent via email between recipients, often the name stays the same and only the last modified date changes.
    If attachments have the same name is it possible to append a version number to the end of the name to identify each individual file?
    Is it possible to maintain the last modified date in the file information? At the moment it appears the creation date is carried with each file.

  9. sorry from AIX background and thought the macro would create the folder as well, I didn’t read it and I should of. Where do the files go if you put a destination that doesn’t exist?

  10. Hi Jim,

    I can not find the instructions within the Zip file to see how it works. Can you help please..Thanks Chris

  11. I used the macro in outlook 2010 and as the names of the attachments are all same, but different content, it didn’t add them in the designated folder and it deleted them all. had to request to have mails resent. What to add in the script to rename the file on name collision?

  12. I modified the code once again to avoid name collision and leaves the original emails intact:

    Sub SaveAttachment()

    ‘Declaration
    Dim myItems, myItem, myAttachments, myAttachment As Object
    Dim myOrt As String
    Dim myOlApp As New Outlook.Application
    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection
    Dim num As Integer
    Dim fileName As String

    ‘Ask for destination folder
    myOrt = InputBox(“Destination”, “Save Attachments”, “C:\”)

    On Error Resume Next

    ‘work on selected item
    Set myOlExp = myOlApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection

    ‘for all items do…
    For Each myItem In myOlSel

    ‘point on attachments
    Set myAttachments = myItem.Attachments

    ‘if there are some…
    If myAttachments.Count > 0 Then

    ‘for all attachments do…
    For i = 1 To myAttachments.Count

    ‘save them to destination
    fileName = CStr(num)
    myAttachments(i).SaveAsFile myOrt & _
    fileName & _
    myAttachments(i).DisplayName
    num = num + 1

    Next i

    End If

    Next

    ‘free variables
    Set myItems = Nothing
    Set myItem = Nothing
    Set myAttachments = Nothing
    Set myAttachment = Nothing
    Set myOlApp = Nothing
    Set myOlExp = Nothing
    Set myOlSel = Nothing

    End Sub

    Hope this helps!

  13. This code works almost perfectly. It saves to much. It also save the .jpeg-files attached to the signature.
    Is it possible only to save the “real” attachment?

  14. thank you Jing!

    solved the:

    1. removing attachments from e-mails after download and;

    2. overwriting files with same names on hard drive

    you’re a genius! God bless you man 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.