Question : Help with vba code that zips outlook attachments...

I'm writing some MS Access vba code that sends out emails/attachments.
If there are more than 4 attachments, I'm trying to get it to zip them using a shell command that calls WinZip.
Winzip gives me an error box that displays all the attachment names, but says that it can't find the files to zip.
How can I pass the contents of attachments to the zip file? My code seems to only pass the names of the attachments...
(I've attached a code snippet of what I have now)
And also, is there a way I can add 'spaces' in the zip destination filename using the shell method? I found that I had to remove the spaces in the zip destination filename since it mistakes it for a source object.

Thanks for any suggestions :)
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
If CountOfFile > 4 Then
       Answer2 = MsgBox("There are 5 or more files to be sent in the " & rst!SCID & vbNewLine & "email record. Would you like to zip them?", vbYesNo, "Zip Files")
       If Answer2 = 6 Then 'User Selected Yes
           For i = 1 To objMailMessage.Attachments.Count
               ZipFiles = ZipFiles & objMailMessage.Attachments.Item(i) & " "
           Next i
           Shell "C:\Program Files\WinZip\WINZIP32.EXE -a -r " & rst!ZipFileName & " " & ZipFiles
       End If
End If
Open in New Window Select All

Answer : Help with vba code that zips outlook attachments...

Hi, Bill543.

You have to save the attachments to disk and then zip them.  
Random Solutions  
 
programming4us programming4us