Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Unicode
Upload
XML
XMP
Zip Compression

More Examples...
Email Object
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA


VB Strings
VB Byte Array

Unreleased...
Bzip2
LZW
Icon

 

 

 

 

 

 

 

Zip Email Attachments and Send

Download Chilkat Email ActiveX

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



 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.