Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Zip Email Attachments and Send
This VB6 example shows how to add attachments to an email and then Zip-compress them in-memory and send.
' This example demonstrates how to Zip attachments in an email.
Private Sub Browse_Click()
CommonDialog1.ShowOpen
AttachFile.Text = CommonDialog1.FileName
List1.AddItem AttachFile.Text
End Sub
Private Sub Command1_Click()
' Create the mailman object for sending and receiving email.
Dim mailman As New ChilkatMailMan2
mailman.UnlockComponent MailUnlockCode.Text
WorkingMsg.Caption = "Working..."
WorkingMsg.Refresh
' Create a new mail object.
Dim email As ChilkatEmail2
Set email = New ChilkatEmail2
email.Body = "This is a test"
email.From = "matt@chilkatsoft.com"
email.AddTo "Matt Fausey", "fausey@chilkatsoft.com"
email.Subject = "Test"
' Add file attachments.
For i = 0 To List1.ListCount - 1
contentType = email.AddFileAttachment(List1.List(i))
Next
' After calling ZipAttachments, all existing email attachments
' will now be contained in a single Zip-file attachment.
email.ZipAttachments "attachments.zip"
' You can save the email as XML and examine it's structure.
email.SaveXml "email.xml"
' Send the email, and save the log which can be checked for errors.
' SendEmail returns 1 for success and 0 for failure.
mailman.SmtpHost = SmtpServer.Text
success = mailman.SendEmail(email)
If (success = 0) Then
' Failed
MsgBox mailman.LastErrorText
End If
mailman.SaveLastError "log.xml"
WorkingMsg.Caption = "Finished."
End Sub
|
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.