Extracting all attachments from Outlook to your computer– not one by one

Following up on the popular Extracting Email address from outlook folder and the How to search for folder name in Outlook, and the How to search for Outlook folder by name  I have been asked the following:

“Great response and very helpful. I have one similar problem I just can’t find a resolution to …. In one of my outlook folders I have many hundreds of emails many have attachments – I want to extract all the attachments into a folder (not an outlook folder). I can do this but only one at a time. Is there any way of selecting a bunch of emails and extracting all the attachments at once?“

So I had a look at outlook and sure enough there is no simple way to extract all the attachments of every email in a folder without going through each mail one by one.

There has to be a better way !

So I wrote a little Macro that will do this for you in one simple click Smile

As per usual: when it comes to these things, I have to add my “I take no responsibility whatsoever if this Macro doesn’t work of messes up your Outlook”

I suggest backing it up before you continue further… (gotta say this for legal reasons)

Now that you have backed up your work, please continue:

1. Open Outlook

2. Right-click on this File and save it to your computer where you can find it again. Once it is downloaded, extract the one file in there and place it in the MY DOCUMENTS folder.

3.  In the ZIP file you have just downloaded is the Macro file. So now we need to Import it into Outlook.

4. Outlook 2010: You need to enable the DEVELOPER ribbon (if you haven’t already done so). It looks like this:


If you dont have it enabled, then just do the following:

Click on File, Options, Customize Ribbon and then put a Tick on the Developer on the right-hand side.


Click OK and it will appear.

5. Click on Developer and then click on Visual Basic

6. Click on File, Import File

7. Select the extracted file : GetEmailAttachments.bas and click on Open


8. Click on File, Close and Return to Outlook

You are now ready to use this !

Simple click on Developer tab, click on Macros and then Macros again, select the GetEmailAttachments and click on Run !


You will now find under your My Documents folder a new Folder called Email Attachments where all your attachments will be saved.

Hope this helps !


on “Extracting all attachments from Outlook to your computer– not one by one
95 Comments on “Extracting all attachments from Outlook to your computer– not one by one
  1. Excellent, thank you so much for this.
    For the people that have problems with the cluttered Inbox, your suggestion of splitting the messages into 350 per folder worked perfectly.

  2. Dear Mr. Liron Segev. Thank you for sharing your code! It worked for me in Outlook 2013 exactly as is! It only took 10 minutes to extract 276 MP3s weighing in at 10.7GB! You saved me about four and a half hours of time, not to mention the astronomical mental health bills I would have acquired if I had to extract all those files manually!

    Thanks again, you rock!

  3. It works perfect when the emails are not archived. What if the email has been archived on a particular folder? It seems that it stops when I reach the archived emails.

    • We got around this by editing the VBA code as follows:

      We put the “Set fso = Nothing” below the if statement:

      ‘ Show summary message
      If i > 0 Then
      MsgBox “There were ” & i & ” attached files.” _
      & vbCrLf & “These have been saved to the Email Attachments folder in My Documents.” _
      & vbCrLf & vbCrLf & “Thank you for using Liron Segev – TheTechieGuy’s utility”, vbInformation, “Export Complete”
      MsgBox “There were no attachments found in any mails.”, vbInformation, “Export – Not Found”
      End If
      Set fso = Nothing

      We replaced the “FileName = WheretosaveFolder & “\” & Atmt.FileName” with the following line:

      FileName = WheretosaveFolder & “\” & fso.GetBaseName(Atmt.FileName) & i & “.” & fso.GetExtensionName(Atmt.FileName)

      Thanks for a great macro this saved me a lot of time.

      • Hi Andrew,

        Very smart indeed. The question I have is does the file up in the thread have this added VBA code in it? If not, could you be so kind as to post the updated code file that does not save duplicate attachments? I would appreciate it a lot. Thanks.

      • Andrew, I appreciate the quick response. Something isn’t working for me though. I added “Set fso = Nothing” after the End If in the “Show summary Message” block and replaced the line mentioned to:

        FileName = WheretosaveFolder & “\” & fso.GetBaseName(Atmt.FileName) & i & “.” & fso.GetExtensionName(Atmt.FileName)

        After I execute it and select the email folder that contains the attachments, I get the error:

        An unexpected error has occurred.
        Macro Name: GetAttachments
        Error Number: 91
        Error Description: Object variable or With block variable not set

        I’m not familiar with VB code so it probably is something silly but I can’t see it.

        Thank you in advance

        • Shelli make sure you moved the “Set fso = Nothing” from the top of the code. There is one at the top and i believe that is what is causing this issue. If you just added this line than the code at the top of the file is still there….

          Sub GetAttachments()
          On Error Resume Next
          ‘create the folder if it doesnt exists:
          Dim fso, ttxtfile, txtfile, WheretosaveFolder
          Dim objFolders As Object
          Set objFolders = CreateObject(“WScript.Shell”).SpecialFolders

          ‘MsgBox objFolders(“mydocuments”)
          ttxtfile = objFolders(“mydocuments”)

          Set fso = CreateObject(“Scripting.FileSystemObject”)
          Set txtfile = fso.CreateFolder(ttxtfile & “\Email Attachments”)
          ————–> Set fso = Nothing

  4. I’d be glad to but I sadly cannot attach the file as this comment field does not allow for attachments.

    To the author, do you have a way that i could send this file to you or do you have a github account i can submit the changes to?

Add your comment