Hi
I am trying to create a script in Outlook that runs on all new messages with attachment.
I want it to :
1. save attachment (I know it will be a password protected zip file)
2. extract contents of zip file using 7zip to specofic location
I've been fiddling with the following code, but I can't seem to get it to work.. it does save the attachment but it doesn't extract the contents.. sometimes I can get it to extract but 7zip prompts every time that the file exists and would I like to overwrite it/Quit etc. even though I am 100% sure the target file isn't in the location..
I regret to admit that I have NO knowledge about VBA.. at all.. I usually work in Powershell... The below code I gleaned from the internet and just kindda tried stuff.. :-)
I am hoping someone will correct the code so I have a usable script..
here's the code:
Public Sub saveAttachtoDisk(itm As Outlook.MailItem) Dim objAtt As Outlook.Attachment Dim saveFolder As String saveFolder = "c:\temp" Dim objShell As Object Set objShell = CreateObject("Wscript.Shell") For Each objAtt In itm.Attachments objAtt.SaveAsFile saveFolder & "\" & objAtt.FileName objShell.Run """C:\Program Files\7-Zip\7z.exe"" e -aoap56suwBfbNd & saveFolder & " \ " & objAtt.FileName & """"" Set objAtt = Nothing Set objShell = Nothing Next End Sub