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

 

 

 

 

 

 

 

Using All-or-None and GetBadEmailAddresses

Download Chilkat Email ActiveX

This example program demonstrates how to use the all-or-none mailman property to prevent sending an email that contains a bad email address. If a bad email address is detected by the SMTP server, this example re-builds the "To" recipient list to send to only good email addresses. Note: Not all SMTP servers will do MX lookups to report bad email addresses.

    Dim mailman As New ChilkatMailMan2
    mailman.UnlockComponent "test"
    
    mailman.SmtpHost = "smtp.comcast.net"
    
    ' If the SMTP server complains about any email address,
    ' this example will re-send without the bad email addresses.
    mailman.AllOrNone = 1
    
    Dim email As New ChilkatEmail2
    email.Subject = "this is a test 3"
    email.From = "Chilkat Support <support@chilkatsoft.com>"
    email.AddTo "", "intentionallyBadEmailAddress@blahblahblah123a.com"
    email.AddTo "", "intentionallyBadEmailAddress@blahblahblah123b.com"
    email.AddTo "", "intentionallyBadEmailAddress@blahblahblah123c.com"
    email.AddTo "Matt Fausey", "matt@chilkatsoft.com"
    email.AddTo "M Fausey", "fausey@chilkatsoft.com"
    email.Body = "this is a test email 3"
    
    success = mailman.SendEmail(email)
    Text2.Text = mailman.LastErrorText
    
    If (success = 0) Then
        ' Some email addresses were bad...
        ' (Be sure to add a reference to Chilkat Util to get the CkStringArray object.)
        Dim aBad As New CkStringArray
        mailman.GetBadEmailAddresses aBad
        
        ' Display the bad email addresses.
        n = aBad.Count
        List1.AddItem Str(n)
        For i = 0 To n - 1
            List1.AddItem aBad.GetString(i)
        Next
        
        ' Get the To addresses as a string array.
        Dim aTo As New CkStringArray
        n = email.NumTo
        For i = 0 To n - 1
            aTo.Append email.GetTo(i)
        Next
        
        ' Loop over the bad email addresses and remove them from aTemp
        n = aBad.Count
        For i = 0 To n - 1
            aTo.Remove aBad.GetString(i)
        Next
        
        ' Clear the To recipients in the email.
        email.ClearTo
        
        ' Build a string containing all the email addresses.
        n = aTo.Count
        Dim toStr As String
        toStr = aTo.GetString(0)
        For i = 1 To n - 1
            toStr = toStr + ", " + aTo.GetString(i)
        Next
        
        ' Add only the already-verified recipients.
        email.AddMultipleTo toStr
        
        ' Re-send.
        success = mailman.SendEmail(email)

    End If
    
    

 

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

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