---
description: When you receive an attachment in “.zip” file extension, if you want to unzip them, in general, you should save and unzip them in local drive. But many hope to unzip them directly in Outlook. This article will teach you how to get it via VBA.
title: How to Unzip the .Zip Attachments Directly in Outlook via VBA
image: https://www.datanumen.com/blogs/wp-content/uploads/2017/05/unzip-the-zip-attachments-directly-in-outlook-via-vba.jpg
---

-
-
-

[Home](https://www.datanumen.com/blogs/) > [Solutions](https://www.datanumen.com/blogs/category/solutions/) > [Office Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/) > [Outlook Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/outlook-solutions/) > How to Unzip the .Zip Attachments Directly in Outlook via VBA

# How to Unzip the .Zip Attachments Directly in Outlook via VBA

[Outlook Solutions](https://www.datanumen.com/blogs/category/solutions/office-solutions/outlook-solutions/) September 29, 2025

Share Now:

-
-
-
-
-
-
-
-

*When you receive an attachment in “.zip” file extension, if you want to unzip them, in general, you should save and unzip them in local drive. But many hope to unzip them directly in Outlook. This article will teach you how to get it via VBA.*

You must have ever received the attachments which are in “.zip” file extension. In order to access the internal files in one zip file, you have to firstly unzip it. In this case, as usual, you have to first save the zip file to local drive and then right click it and select “Extract All” from the context menu. In reality, many users prefer to unzip the file directly within Outlook. However, Outlook does not provide such a native feature. Fortunately, you can follow the steps thereinafter to utilize VBA to realize it like a breeze.

![Unzip the .Zip Attachments Directly in Outlook via VBA](https://www.datanumen.com/blogs/wp-content/uploads/2017/05/unzip-the-zip-attachments-directly-in-outlook-via-vba.jpg "Unzip the .Zip Attachments Directly in Outlook via VBA")

## Unzip the .Zip Attachments Directly in Outlook

1. In the first place, launch your Outlook application.
2. Then press “Alt + F11” key shortcut in Outlook window to access VBA editor.
3. Next in the “Microsoft Visual Basic for Applications” window, open a module that is not in use.
4. Subsequently, copy and paste the following VBA codes into this module.

```
Public Sub UnzipFileInOutlook()
    Dim objMail As Outlook.MailItem
    Dim objAttachments As Outlook.attachments
    Dim objAttachment As Outlook.Attachment
    Dim objShell As Object
    Dim objFileSystem As Object
    Dim strTempFolder As String
    Dim strFilePath As String
    Dim strFileName As String
 
    Set objMail = Outlook.Application.ActiveInspector.CurrentItem
    Set objAttachments = objMail.attachments
 
    'Save & Unzip the zip file in local drive
    Set objShell = CreateObject("Shell.Application")
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    strTempFolder = objFileSystem.GetSpecialFolder(2).Path & "\Temp" & Format(Now, "yyyy-mm-dd-hh-mm-ss")
    MkDir (strTempFolder)
 
    For Each objAttachment In objAttachments
        If Right(objAttachment.FileName, 3) = "zip" Then
           strFilePath = strTempFolder & "\" & objAttachment.FileName
           objAttachment.SaveAsFile (strFilePath)
           objShell.NameSpace((strTempFolder)).CopyHere objShell.NameSpace((strFilePath)).Items
        End If
    Next
 
    'Reattach the files extracted from the zip file
    strFileName = Dir(strTempFolder & "\")
 
    While Len(strFileName) > 0
          objMail.attachments.Add (strTempFolder & "\" & strFileName)
          strFileName = Dir
          objMail.Save
    Wend
 
    'Delete the attachments in “.zip” file extension
    Set objAttachments = objMail.attachments
    For Each objAttachment In objAttachments
        If Right(objAttachment.FileName, 3) = "zip" Then
           objAttachment.Delete
           objMail.Save
        End If
    Next
 
    'Delete the temp folder and files
    objFileSystem.DeleteFolder (strTempFolder)
End Sub
```

![VBA Code - Unzip the .Zip Attachments Directly in Outlook](<> "VBA Code - Unzip the .Zip Attachments Directly in Outlook")

5. After that, you can add the new VBA project to the Quick Access Toolbar of message window as usual.
6. Finally, you can have a try.

- First, open a message with zip file in its own window.
- Then click “Actions” > “Edit Message”.
- Next click the new macro button in Quick Access Toolbar.
- At once, the zip file will unzipped, like the following screenshot:![Unzip File](<> "Unzip File")

## Get Rid of Annoying PST Issues

Though the PST file in new Unicode format supports 20 GB file size, it’s still wise to keep file as small as possible. It is because that a large PST file is much more prone to corruption. Once your PST file gets compromised, you will have to make efforts to [recover PST](https://www.datanumen.com/outlook-repair/) data. In that scenario, you have no choice but to recur to a well-proven and reputable tool like DataNumen Outlook Repair.

## Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including [sql repair](https://www.datanumen.com/sql-recovery/) and outlook repair software products. For more information visit [www.datanumen.com](https://www.datanumen.com/)

Share Now:

-
-
-
-
-
-
-
-

[← Previous post](https://www.datanumen.com/blogs/15-effective-tips-prevent-memory-card-corruption/)

[Next post →](https://www.datanumen.com/blogs/batch-find-replace-specific-words-outlook-folder-names/)

Comments are closed.

![Data Recovery Blog]()

Follow or like us on Facebook, LinkedIn and Twitter to get all promotions, latest news and updates on our products and company.

-
-
-

### Featured Products

- [DataNumen Outlook Repair](https://www.datanumen.com/outlook-repair/)
- [DataNumen SQL Recovery](https://www.datanumen.com/sql-recovery/)
- [DataNumen Exchange Recovery](https://www.datanumen.com/exchange-recovery/)
- [DataNumen Access Repair](https://www.datanumen.com/access-repair/)
- [DataNumen Excel Repair](https://www.datanumen.com/excel-repair/)
- [DataNumen PDF Repair](https://www.datanumen.com/pdf-repair/)
- [DataNumen Word Repair](https://www.datanumen.com/word-repair/)
- [DataNumen Zip Repair](https://www.datanumen.com/zip-repair/)

### Popular posts

```json
{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/#article","isPartOf":{"@id":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/"},"author":{"name":"AuthorCCW","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/person\/33ded6c47c77587f9158d99f05e23957"},"headline":"How to Unzip the .Zip Attachments Directly in Outlook via VBA","datePublished":"2017-05-06T04:07:37+00:00","dateModified":"2025-09-29T10:51:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/"},"wordCount":387,"commentCount":1,"publisher":{"@id":"https:\/\/www.datanumen.com\/blogs\/#organization"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/unzip-the-zip-attachments-directly-in-outlook-via-vba.jpg","articleSection":["Outlook Solutions"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/","url":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/","name":"How to Unzip the .Zip Attachments Directly in Outlook via VBA","isPartOf":{"@id":"https:\/\/www.datanumen.com\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/#primaryimage"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/unzip-the-zip-attachments-directly-in-outlook-via-vba.jpg","datePublished":"2017-05-06T04:07:37+00:00","dateModified":"2025-09-29T10:51:29+00:00","description":"When you receive an attachment in “.zip” file extension, if you want to unzip them, in general, you should save and unzip them in local drive. But many hope to unzip them directly in Outlook. This article will teach you how to get it via VBA.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanumen.com\/blogs\/unzip-zip-attachments-directly-outlook-via-vba\/#primaryimage","url":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/unzip-the-zip-attachments-directly-in-outlook-via-vba.jpg","contentUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/unzip-the-zip-attachments-directly-in-outlook-via-vba.jpg","width":531,"height":340,"caption":"Unzip the .Zip Attachments Directly in Outlook via VBA"},{"@type":"WebSite","@id":"https:\/\/www.datanumen.com\/blogs\/#website","url":"https:\/\/www.datanumen.com\/blogs\/","name":"Data Recovery Blog","description":"Discuss every aspect of data recovery","publisher":{"@id":"https:\/\/www.datanumen.com\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.datanumen.com\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.datanumen.com\/blogs\/#organization","name":"Data Recovery Blog","url":"https:\/\/www.datanumen.com\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2019\/02\/logowithouttext.jpg","contentUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2019\/02\/logowithouttext.jpg","width":296,"height":397,"caption":"Data Recovery Blog"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataNumen","https:\/\/x.com\/DataNumen","http:\/\/www.linkedin.com\/company\/datanumen","https:\/\/myspace.com\/datanumen\/","http:\/\/www.pinterest.com\/datanumen\/","https:\/\/www.youtube.com\/channel\/UCVIIuuKfUBHSJauUaVP13tw"]},{"@type":"Person","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/person\/33ded6c47c77587f9158d99f05e23957","name":"AuthorCCW","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3516ed90fc242780d3947a989f895bc46e70c3e83485d30f2b457a007906aa58?s=96&d=mm&r=g","caption":"AuthorCCW"},"sameAs":["https:\/\/www.datanumen.com\/"]}]}
```
