How to Unrar .RAR Prílohy priamo v Outlooku cez VBA

Zdieľať teraz:

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”Prílohy iba v Outlooku. Teraz čítajte ďalej a získate podrobné kroky a kódy VBA.

unrar .RAR Prílohy priamo v Outlooku cez VBA

unrar .RAR Prílohy priamo v Outlooku

  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. Potom by ste mohli otvoriť aplikáciu Outlook ako obvykle.
  3. Ďalej stlačte „Alt + F11“ v hlavnom okne Outlooku.
  4. Následne v editore Outlook VBA otvorte prázdny modul.
  5. A potom skopírujte nasledujúci kód VBA do tohto modulu.
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 Prílohy priamo v Outlooku

  1. Potom sa musíte ubezpečiť, že je vo vašom Outlooku povolené makro.
  2. Nakoniec to môžete vyskúšať.
  • Firstly, open an email which contains .RAR prílohy.
  • Potom späť na tlačidlo nového makra.
  • Click into “UnRARAttachments” subroutine and press F5.
  • Potom kliknite na nasledujúci podprogram „AttachExtractedFiles“ a stlačte kláves F5.
  • After that, you can turn back to the mail window. You will see that .RAR prílohy boli dekomprimované. Všetky extrahované súbory sú pripojené.unrar RAR prílohy

Rozbaľte .Zip Prílohy v Outlooku

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”Prílohy predvolene priamo v Outlooku. Našťastie stále môžete na dosiahnutie tejto funkcie využiť Outlook VBA. Viac podrobností nájdete v mojom predchádzajúcom článku - „How to Unzip the .Zip Prílohy priamo v Outlooku cez VBA".

Úvod autora:

Shirley Zhang je expertkou na obnovu dát v DataNumen, Inc., ktorá je svetovým lídrom v oblasti technológií obnovy dát, vrátane fixné SQL Server a výhľadové softvérové ​​produkty na opravu. Pre viac informácií navštívte www.datanumen. S

Zdieľať teraz:

Komentáre sú uzavreté.