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

 

 

 

 

 

 

 

SMTP Load Balancing with SMTPQ

Download Chilkat Email ActiveX

Demonstrates how to use the SMTPQ background Windows service to send email to a list of recipients using multiple SMTP servers simultaneously.

    ' This example demonstrates how to use multiple SMTP servers
    ' to send an email notification to many customers.
    ' The program loads a list of email addresses from a text file
    ' (one email address per line) and a list of SMTP server hostnames
    ' from a file (one hostname per line) and then
    ' sends the email to each recipient via the Chilkat SMTPQ background
    ' service.  The SMTP servers are used in a round-robin fashion to
    ' achieve parallelism.  The SendQ method deposits an email into the
    ' SMTPQ's queue directory.  Information about the SMTP hostname and
    ' SMTP login/password is embedded in the queued file so that when
    ' the SMTPQ process loads the file, it extracts the SMTP information,
    ' connects to the SMTP server specified (and potentially authenticates),
    ' and sends the email.
    '
    ' The SMTPQ service should be configured to use a number of threads equal
    ' to the number of SMTP servers used.  This provides for an even load balancing
    ' of emails across SMTP servers.
    '
    ' NOTE: This example program uses the CkStringArray object, which requires
    ' a reference to the ChilkatUtil object to be added to the VB6 project.
    Dim smtpServers As New CkStringArray
    Dim emailAddresses As New CkStringArray
    
    smtpServers.LoadFromFile "smtpServers.txt"
    emailAddresses.LoadFromFile "emailAddresses.txt"
    
    ' Assume we previously save an email as a .eml and this is going to be sent.
    ' We only need to change the recipient for each email.
    Dim email As New ChilkatEmail2
    email.LoadEml "myEmail.eml"

    Dim smtpIdx As Integer
    smtpIdx = 0
    
    Dim mailman As New ChilkatMailMan2
    mailman.UnlockComponent "Anything for 30-day trial"
    
    ' Loop over the email addresses.
    For i = 0 To emailAddresses.Count - 1
    
        email.ClearTo
        email.AddTo "", emailAddresses.GetString(i)
        
        mailman.SmtpHost = smtpServers.GetString(smtpIdx)
        
        success = mailman.SendQ(email)
        If (success = 0) Then
            ' Failed!
            ' .... handle this however you decide...
        End If
        
        ' Move to the next SMTP server.
        smtpIdx = smtpIdx + 1
        If (smtpIdx = smtpServers.Count) Then
            smtpIdx = 0
        End If
        
    Next

 

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

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