一般來說,要解壓“.rar對於電子郵件中的附件,您應該先儲存它,然後使用專門的工具提取內部文件。本文將為您提供一種直接在 Outlook 中解壓縮 rar 檔案的方法。
Outlook 不允許您預覽「.RAR附件。此外,您無法解壓縮“.RAR無法直接在 Outlook 中開啟附件。因此,如果您想查看此類附件,應先將其儲存到本機磁碟器,然後使用 WinRAR 等專用工具從中提取內部文件。針對此問題,我們將為您提供一種解壓縮“.RAR”附件僅在Outlook中。 現在繼續閱讀以獲得詳細的步驟和VBA代碼。

的unrar .RAR 直接在Outlook中的附件
- 首先,由於此方法依賴特定的工具——WinRAR,您應該先將其安裝到您的電腦上,並確保其安裝位置正確。
- 然後,您可以照常打開Outlook應用程序。
- 接下來,在Outlook主窗口中按“ Alt + F11”鍵按鈕。
- 隨後,在Outlook VBA編輯器中,打開一個空模塊。
- 然後將以下VBA代碼複製到此模塊中。
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
- 之後,您需要確保Outlook中允許使用宏。
- 最後,您可以嘗試一下。
- 首先,開啟一封包含以下內容的電子郵件 .RAR 附件。
- 然後回到新的宏按鈕。
- 點選進入「UnRARAttachments」子程序,然後按F5鍵。
- 然後單擊下面的“ AttachExtractedFiles”子例程,然後按F5鍵。
- 之後,您可以返回郵件視窗。您會看到 .RAR 附件已解壓縮。 所有提取的文件均已附加。
拉開拉鍊 .Zip Outlook中的附件
就像解壓縮一樣 .RAR 對於附件,Outlook 沒有原生功能來解壓縮“.zip”附件。因此,如果您無法直接解壓縮“.Zip”默認情況下直接在Outlook中添加“”附件。 幸運的是,您仍然可以使用Outlook VBA來實現此功能。 有關更多詳細信息,您可以查看我以前的文章-“如何解壓縮 .Zip 通過VBA直接在Outlook中附件“。
作者簡介:
Shirley Zhang是的數據恢復專家 DataNumen,Inc.是數據恢復技術的全球領導者,包括 固定 SQL Server 和Outlook修復軟件產品。 欲了解更多信息,請訪問 萬維網。datanumen.COM

