Sending Email attaching a Zip file

Terry P

Active Member
Joined
Nov 28, 2002
Messages
256
I am able to zip the active Workbook but I need to email the zipped file rather than the Workbook.
Any ideas please?
This message was edited by Terry P on 2002-12-07 10:22
 
I tested this one. The other one may not work as is. Fix it by downloading the command line utility and looking at the syntax. This will simply zip up one file and email it to the address defined.<pre>Option Explicit

Sub SendFiles()
Dim SendAddress As String, ZipFile As String, ZipList As String
Dim ShellString As String, FileToZip As String

'full path of the file you will be zipping up
FileToZip = "the full path of the file you want to zip"

'full path of the zip file you will be creating
ZipFile = "the full path of the zip file"

'defining the full argument to pass to the following shell function
ShellString = "C:Program FilesWinZipwzzip.exe " & ZipFile & " " & FileToZip

'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

'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
.Send False
DoEvents
End With
Unload UserForm1
DoEvents
send_mail = True
Exit Function
ErrHandler:
End Function</pre>
Tom
 
Upvote 0
Tom
That looks great I hope to try it out this week and will get back to you asap.
Thanks for your kind help
Terry
 
Upvote 0
Tom
I have no idea how to add the MAPI controls to the Userform I've created.

Please help
Terry
PS Bed beckons, I'll be back on tommorow
This message was edited by Terry P on 2002-12-08 19:54
 
Upvote 0
From the VBAIDE, right click on the Toolbox, choose "Additional Controls", place a check next to "Microsoft MAPI Messages" and "Microsoft MAPI Session". They will now be on your toolbox. Simply draw them out on your form. These controls are not visible during runtime.
Tom
 
Upvote 0
Terry,

Is it on Your machine or does the problem occur on some user machine?

Kind regards,
Dennis
 
Upvote 0
Terry,

I´ve made some further investigation to this.

I think that MAPI as well as other controls require a developer license (Office Developer or Visual Basic Pro / Enterprise) in order to be used.

Since I do have them both I had no problem to run Tom´s solution.

This is subject to MS licence rules....

Please try Ivan´s solution and see if You can use his solution instead.

Kind regards,
Dennis
 
Upvote 0
Thought so. Never mind, I am sure you got something out of it. Afterall that's what it's all about.
I am still bearing Ivan's idea & commail in mind.
Thanks so very much for your all of your welcomed help.
Terry
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top