Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component

  

  

  Chilkat ActiveX Components

  Chilkat .NET Components

  Chilkat C++ Libraries

  

  

  

  

 

FAQ

DOWNLOAD ReferenceVersions

Alternative Bodies

Chilkat Mail allows you to easily provide alternative mail bodies. The most common use is to send both HTML and plain-text bodies, such that email clients that can handle HTML will display a more appealing email, while those that cannot will display a simple text message.

A Simple Example: Sending an email with both plain-text and HTML bodies

    Dim mailman As Object
    Set mailman = CreateObject("ChilkatMail.ChilkatMailMan")
    
    ' Get the free unlock-code from http://www.chilkatsoft.com
    mailman.UnlockComponent "unlock-code"
    mailman.SmtpHost = "smtp.mail.yahoo.com"
    mailman.SmtpUsername = "chilkat_software"
    mailman.SmtpPassword = "my_password"
    
    Set email = New ChilkatEmail
    email.AddTo "John Smith", "jsmith@chilkatsoft.com"
    email.Subject = "This email has alternative bodies"
    email.AddPlainTextAlternativeBody "This is the plain-text body"
    email.AddHtmlAlternativeBody "<html><head></head><body>This is the HTML body</body></html>"
    email.From = "chilkat_software@yahoo.com"
    mailman.SendEmail email
    Set email = Nothing
    
    Set mailman = Nothing
 

Receiving Emails with Alternative Bodies

ChilkatMail allows your application to easily detect whether multiple bodies are present, and to access any of the easily. Below is a fragment of code that shows how.

    Set bundle = mailman.CopyMail
    MessageCount = bundle.MessageCount
    Dim email As ChilkatEmail
    For i = 0 To MessageCount - 1
    
        Set email = bundle.GetEmail(i)
        
        If (email.NumAlternatives > 0) Then
            ' This email has alternative bodies.

            ' If an HTML alternative does not exist, htmlBody will be
            ' an empty string.
            htmlBody = email.GetHtmlBody()
            
            ' If a plain text alternative does not exist, plainTextBody
            ' will be an empty string.
            plainTextBody = email.GetPlainTextBody()
            
            ' You can access any of the alternative bodies like this...
            numAlternatives = email.NumAlternatives
            For j = 0 To numAlternatives - 1
                contentType = email.GetAlternativeContentType(j)
                altBody = email.GetAlternativeBody(j)

                ' Application code can go here to do something...
            Next
            
        Else
            ' This email has no alternative bodies.
            ' Application code can go here to do something...
        End If
        
        Set email = Nothing
    Next


Privacy Statement. Copyright 2000-2010 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows 7, Vista, XP, 2000, 2003 Server, and Windows 95/98/NT4.