Try this out. This code was edited on the fly from a VB project but you should be able to adapt it. Let me know if you have any problems. I'll post a slimmed down version for zipping only one file in a few moments.
Create a user form(useform1) draw out the two mapi controls. There is no code on the form and the form will not actually be shown, only loaded.<pre>Option Explicit
Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Sub SendFiles()
Dim fs As New FileSystemObject, f As Folder, ff As Files, f1 As file, n As Long
Dim SendAddress As String, ZipFile As String, ZipList As String, ShellString As String
'there are a bunch of files in this folder which are added to a list file.
'is a simple text file which will be used by Winip's commandline
If fs.FolderExists("L:Whse_DroplotDroplot ArchiveLRDTMessages") Then
Set f = fs.GetFolder("L:Whse_DroplotDroplot ArchiveLRDTMessages")
Set ff = f.Files
For Each f1 In ff
CreateZipFile f1.Path
Next
End If
'defining the zip files full path to use as an argument
ZipFile = "C:JBDCSCollectorLRDT_DATA_" & Format(Now - 1, "MMDDYYYY") & ".zip"
'defining the list text files path to use as an argument
ZipList = "C:JBDCSCollectorLRDT_DATA_" & Format(Now - 1, "MMDDYYYY") & ".LST"
'defining the full argument to pass to the following shell function
ShellString = "C:Program FilesWinZipwzzip.exe " & ZipFile & " @" & ZipList
'run the shell on winzip's command line utility. Zips up all of the files in the
'list file into one zip file
Shell ShellString
'this procedure is called in a loop. You may or may not need this
'I just wanted to slow down the mailing a bit to avoid runtime problems
Sleep 10000
'define the address you will be mailing to
SendAddress = "tstom@hotmail.com"
If Not send_mail(SendAddress, "Subject Here", "Body Here", ZipFile) Then MsgBox "Failed"
End Sub
Public Function send_mail(sendto As String, subject As String, _
text As String, AttachPath As String) As Boolean
'Add The MAPI Components and
'add a MAPI Session and MAPI mail control to your form
On Error GoTo ErrHandler
Unload UserForm1
With UserForm1.MAPISession1
.DownLoadMail = False
.LogonUI = True
.SignOn
UserForm1.MAPIMessages1.SessionID = .SessionID
End With
With userform1.MAPIMessages1
.Compose
.RecipAddress = sendto
.AddressResolveUI = True
.ResolveName
.AttachmentPathName = AttachPath
.MsgSubject = subject
.MsgNoteText = text
Sleep 2000
.Send False
DoEvents
End With
Unload UserForm1
DoEvents
send_mail = True
Exit Function
ErrHandler:
End Function</pre>
Tom
Here's the link for the command line utility from Winzip:
http://www.winzip.com/getsite.cgi?wzcline.exe
_________________
Using Office 2000 on Windows 2000
This message was edited by TsTom on 2002-12-08 19:06