|
'Here's something to get you started - you can adjust it to suit your
'needs, multiple attachments, error checking etc.. ***THIS IS BARE BONES***
'In your Outlook VBA Code window paste this into "ThisOutLookSession"
'Then create a new email message with an attachment and click send
'Your email will now have an attachment called "Little.zip"
'Make sure C:\Temp exists, again this is bare bones!
'Assumes pacomp.exe is on your system path
'Tested with Outlook 2003
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
myZipSend
End Sub
Sub myZipSend()
Dim myOlApp As Outlook.Application
Dim myInspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Set myOlApp = CreateObject("Outlook.Application")
Set myInspector = myOlApp.ActiveInspector
If Not TypeName(myInspector) = "Nothing" Then
If TypeName(myInspector.CurrentItem) = "MailItem" Then
Set myItem = myInspector.CurrentItem
Set myAttachments = myItem.Attachments
myAttachments.Item(1).SaveAsFile "C:\Temp\" & myAttachments.Item(1).FileName
Shell "pacomp -a C:\Temp\Little.zip C:\Temp\" & myAttachments.Item(1).FileName, vbHide
myAttachments.Item(1).Delete
Sleep 1000
myAttachments.Add "C:\Temp\Little.zip"
Else
MsgBox "The item is of the wrong type."
End If
End If
End Sub
|