---
description: In general, to unrar the “.rar” attachments in an email, you should firstly save it and then use specific tool to extract internal files. This article will provide you a method to unrar directly in Outlook.
title: How to Unrar .RAR Attachments Directly in Outlook via VBA
image: https://www.datanumen.com/blogs/wp-content/uploads/2017/05/unrar-rar-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 Unrar .RAR Attachments Directly in Outlook via VBA

# How to Unrar .RAR Attachments Directly in Outlook via VBA

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

Share Now:

-
-
-
-
-
-
-
-

*In general, to unrar the “.rar” attachments in an email, you should firstly save it and then use specific tool to extract internal files. This article will provide you a method to unrar directly in Outlook.*

Outlook doesn’t permit you to preview the “.RAR” attachments. Also, you cannot unrar the “.RAR” attachments straightly within Outlook. Therefore, if you wish to view such an attachment, you should firstly save it to local drive and then extract the internal files from it via special utility, such as WinRAR. Focused on this issue, here we will offer you a way, which allows you to unrar “.RAR” attachments just in Outlook. Now read on to get the detailed steps and VBA codes.

![Unrar .RAR Attachments Directly in Outlook via VBA](https://www.datanumen.com/blogs/wp-content/uploads/2017/05/unrar-rar-attachments-directly-in-outlook-via-vba.jpg "Unrar .RAR Attachments Directly in Outlook via VBA")

## Unrar .RAR Attachments Directly in Outlook

1. First of all, as this method relies on a specific tool – WinRAR, you should first install it on your PC and make sure where it is mounted.
2. Then you could open your Outlook application as usual.
3. Next press “Alt + F11” key buttons in the main Outlook window.
4. Subsequently, in the Outlook VBA editor, open an empty module.
5. And then copy the following VBA code into this module.

```
Public objFileSystem As Object
Public strTempFolder As String
Public strTargetFolderPath As String
Public objAttachment As Outlook.Attachment

Sub UnRARAttachment()
    Dim objMail As Outlook.MailItem
    Dim objShell As Object
    Dim strTempFolder As String
    Dim strRARFile As String
 
    Set objMail = Outlook.Application.ActiveInspector.CurrentItem
 
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    strTempFolder = objFileSystem.GetSpecialFolder(2).Path
    strTargetFolderPath = strTempFolder & "\Temp " & Format(Now, "YYYY-MM-DD-hh-mm-ss")
    MkDir (strTargetFolderPath)
 
    Set objShell = CreateObject("Wscript.Shell")
 
    If objMail.attachments.Count > 0 Then
       For Each objAttachment In objMail.attachments
           If LCase(Right(objAttachment.FileName, 4)) = ".rar" Then
 
              strRARFile = strTempFolder & "\" & objAttachment.FileName
              objAttachment.SaveAsFile (strRARFile)
 
              'Change "C:\Program Files\WinRAR\WinRAR.exe" to the location where your WinRAR is installed
              objShell.Run Chr(34) & "C:\Program Files\WinRAR\WinRAR.exe" & Chr(34) & " e " & Chr(34) & strRARFile & Chr(34) & " " & Chr(34) & strTargetFolderPath & Chr(34)
           End If
       Next
    End If
 
End Sub

Sub AttachExtractedFiles()
    Dim strFolderPath As String
    Dim strFile As String
 
    'Attach the extracted files to the current email
    strFolderPath = strTargetFolderPath & "\"
    strFile = Dir(strFolderPath)
 
    Set objMail = Outlook.Application.ActiveInspector.CurrentItem
 
    While Len(strFile) > 0
          objMail.attachments.Add strFolderPath & strFile
          strFile = Dir
    Wend
 
    'Delete the .RAR attachments
    For Each objAttachment In objMail.attachments
        If LCase(Right(objAttachment.FileName, 4)) = ".rar" Then
           objAttachment.Delete
        End If
    Next
End Sub
```

![VBA Code - Unrar .RAR Attachments Directly in Outlook]( "VBA Code - Unrar .RAR Attachments Directly in Outlook")

6. After that, you need to ensure that macro is permitted in your Outlook.
7. Finally you can have a try.

- Firstly, open an email which contains .RAR attachments.
- Then back to the new macro button.
- Click into “UnRARAttachments” subroutine and press F5.
- And next click into the following “AttachExtractedFiles” subroutine and press F5 key.
- After that, you can turn back to the mail window. You will see that .RAR attachments have been decompressed. All the extracted files have been attached.![Unrar RAR Attachments]( "Unrar RAR Attachments")

## Unzip .Zip Attachments in Outlook

Like decompressing the .RAR attachments, Outlook doesn’t have native features to decompress the “.zip” attachments. Therefore, if you’re unable to directly unzip the “.Zip” attachments straightly in Outlook by default. Fortunately, you still can make use of Outlook VBA to achieve this function. For more details, you can check my previous article – “ [How to Unzip the .Zip Attachments Directly in Outlook via VBA](https://www.datanumen.com/blogs/unzip-zip-attachments-directly-outlook-via-vba/)”.

## Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including [fix SQL Server](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/7-causes-solutions-failing-access-data-cd-dvd/)

[Next post →](https://www.datanumen.com/blogs/quickly-get-total-count-items-folder-subfolders-via-outlook-vba/)

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\/unrar-rar-attachments-directly-outlook-via-vba\/#article","isPartOf":{"@id":"https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/"},"author":{"name":"AuthorCCW","@id":"https:\/\/www.datanumen.com\/blogs\/#\/schema\/person\/33ded6c47c77587f9158d99f05e23957"},"headline":"How to Unrar .RAR Attachments Directly in Outlook via VBA","datePublished":"2017-05-16T03:04:16+00:00","dateModified":"2025-09-29T10:51:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/"},"wordCount":388,"commentCount":1,"publisher":{"@id":"https:\/\/www.datanumen.com\/blogs\/#organization"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/unrar-rar-attachments-directly-in-outlook-via-vba.jpg","articleSection":["Outlook Solutions"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/","url":"https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/","name":"How to Unrar .RAR Attachments Directly in Outlook via VBA","isPartOf":{"@id":"https:\/\/www.datanumen.com\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/#primaryimage"},"image":{"@id":"https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/#primaryimage"},"thumbnailUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/unrar-rar-attachments-directly-in-outlook-via-vba.jpg","datePublished":"2017-05-16T03:04:16+00:00","dateModified":"2025-09-29T10:51:02+00:00","description":"In general, to unrar the “.rar” attachments in an email, you should firstly save it and then use specific tool to extract internal files. This article will provide you a method to unrar directly in Outlook.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.datanumen.com\/blogs\/unrar-rar-attachments-directly-outlook-via-vba\/#primaryimage","url":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/unrar-rar-attachments-directly-in-outlook-via-vba.jpg","contentUrl":"https:\/\/www.datanumen.com\/blogs\/wp-content\/uploads\/2017\/05\/unrar-rar-attachments-directly-in-outlook-via-vba.jpg","width":531,"height":340,"caption":"Unrar .RAR 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\/"]}]}
```
