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
SMTP Load Balancing with SMTPQ
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
|
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.