unzip outlook attachments

Hi, I have the following code to save outlook attachments to a folder on arrival. But the attachments are zipped, and want the saved files to be unzipped. Any help much appreciated.

Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String

saveFolder = "C:\Users\brendan\XML Files"
     For Each objAtt In itm.Attachments
          objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
          Set objAtt = Nothing
     Next
End Sub

April 20th, 2015 12:00am

Hi

As per the information and details provided by you, to unzip the Outlook attachments, please follow these steps: -

Sub UnzipAttachment(Item As Outlook.MailItem)

    Dim olkAttachment As Outlook.Attachment, _

        objShell As Object

    Set objShell = CreateObject("Wscript.Shell")

    If Item.Attachments.Count > 0 Then

        For Each olkAttachment In Item.Attachments

            If LCase(Right(olkAttachment.FileName, 4)) = ".zip" Then

                olkAttachment.SaveAsFile "C:\EmailAttachments\" & olkAttachment.FileName

                objShell.Run """C:\Program Files\7-Zip\7z.exe"" e -aoa ""C:\EmailAttachments\" & olkAttachment.FileName & """"

            End If

        Next

    End If

    Set olkAttachment = Nothing

    Set objShell = Nothing

End Sub

I hope this information will be helpful for you.

Thanks and regards

Shweta@G 

Free Windows Admin Tool Kit Click here and download it now
April 20th, 2015 2:04am

You are posting in the wrong forum.  This is a scripting forum and you are asking about Outlook VBA.

There is no built in method in Windows to unzip files. You must use external means.

April 20th, 2015 3:28am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics