I put this in a rule to automate saving a zipped file I get in emails throughout the day:
Public Sub SaveZip(itm As Outlook.MailItem)
Const saveFolder = "C:\Users\Example\Example\Example\"
Dim objAtt As Outlook.Attachment
Dim oApp As Object
Dim dName As Variant, unZipFolder
If itm.Attachments.Count > 0 Then
unZipFolder = saveFolder & "unzipped\"
MkDir unZipFolder
For Each objAtt In itm.Attachments
dName = objAtt.DisplayName
objAtt.SaveAsFile saveFolder & dName
Set oApp = CreateObject("Shell.Application")
oApp.NameSpace(unZipFolder).CopyHere _
oApp.NameSpace(saveFolder & dName).Items
Next
End If 'any attachments
End Sub
It works once then won't work for following emails. Nothing happens after the first file is saved and unzipped.