VB.NET Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB.NET Examples

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

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

Email Distribution List with Mail Merge

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

VB.NET source code example showing how to send email using a distribution list with mail-merge.


        ' Create a mailman object for sending email.
        Dim mailman As New Chilkat.MailMan()

        ' Any string passed to UnlockComponent automatically begins a 30-day trial.
        Dim success As Boolean
        success = mailman.UnlockComponent("Hello World")
        If (success <> true) Then
            MsgBox(mailman.LastErrorText)
            Exit Sub
        End If

        ' Set the SMTP server.
        mailman.SmtpHost = "smtp.earthlink.net"

        ' Create an array of email addresses.
        ' This is where you might load email addresses from a file,
        ' or load email addresses from a database such as Access, SQL Server, Oracle, MySQL, etc.
        Dim array As New Chilkat.StringArray()
        array.Unique = True ' Do not allow duplicates in the array.
        ' Chilkat will be able to parse the full email addresses...
        array.Append("Chilkat Support <support@chilkatsoft.com>")
        array.Append("""Chilkat Sales"" <sales@chilkatsoft.com>")
        array.Append("<matt@chilkatsoft.com>")
        array.Append("joe@chilkatsoft.com")

        Dim email As New Chilkat.Email()

        ' Make this email have both HTML and plain-text alternatives.
        ' Be sure to use CRLF line endings in plain-text email.
        email.AddPlainTextAlternativeBody("Hello CUSTOMER_NAME" + ControlChars.Cr + ControlChars.Lf + "This is a test")
        email.AddHtmlAlternativeBody("<html><body>Hello CUSTOMER_NAME<br>This is a test</body></html>")

        email.Subject = "CUSTOMER_NAME: This is a test."

        email.FromName = "Bob"
        email.FromAddress = "bob@chilkatsoft.com"

        Dim i As Integer
        Dim numEmails As Integer = array.Count

        Dim friendlyName As String
        For i = 0 To numEmails - 1
            email.ClearTo()

            ' We call AddMultipleTo even though we are only adding a single
            ' email address.  AddMultipleTo parses a comma separated list of
            ' email addresses, each of which may or may not include the
            ' friendly name.
            email.AddMultipleTo(array.GetString(i))

            ' Get the friendly name that was in the email address.
            friendlyName = email.GetToName(0)
            If friendlyName.Length = 0 Then
                friendlyName = friendlyName + "Customer"
            End If
            ' Set the replacement pattern.  When the email is sent, all occurances of 
            ' CUSTOMER_NAME are replaced with the replacement string.
            email.SetReplacePattern("CUSTOMER_NAME", friendlyName)

            ' The email can have any number of replacement patterns.  Simply 
            ' set a replace pattern for each.  
            ' email.SetReplacePattern("PATTERN2","replacement2");
            ' email.SetReplacePattern("PATTERN3","replacement3");
            Dim sendQueued As Boolean = True

            ' One option is to send the email in the background using the SMTPQ service:
            If sendQueued Then
                ' Sending the email using SMTPQ allows for emails to be sent by multiple
                ' threads simultaneously by the SMTPQ process.  The email sending will 
                ' also survive system reboots / crashes because it will resume when the
                ' service restarts on system startup.
                If Not mailman.SendQ(email) Then
                    ' We could send the email in-process:
                    MessageBox.Show(mailman.LastErrorText)
                    Exit For
                End If
            Else
                ' Or... the mail can be sent in-process.
                If Not mailman.SendEmail(email) Then
                    ' We could send the email in-process:
                    MessageBox.Show(mailman.LastErrorText)
                    Exit For
                End If
            End If
        Next i

 

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

Mail Component · XML Parser