AltBody Property


This property specifies alternative body of current email.

Data Type: String

Remarks

In some cases, an email consists of two bodies. One is in text/html format, and another one is in text/plain format. It is called multipart/alternative format. AltBody property specifies text/plain part of an email. Why alternative? Suppose that the recipient's email client doesn't support html email, if AltBody is specified, email client will shows the AltBody.

BodyFormat property must be set to 1 (text/html) to take effect.

Examples

[VB, VC++] To get the full samples of EASendMail, please refer to Samples section.

[VB6, VBA - Send Email with Alternative Body]
Const ConnectNormal = 0
Const ConnectSSLAuto = 1
Const ConnectSTARTTLS = 2
Const ConnectDirectSSL = 3
Const ConnectTryTLS = 4

Private Sub SendEmail()
    Dim oSmtp As EASendMailObjLib.Mail
    Set oSmtp = New EASendMailObjLib.Mail

    ' for evaluation usage, please use "TryIt" as the license code.
    oSmtp.LicenseCode = "TryIt"
  
    ' Your SMTP server address
    oSmtp.ServerAddr = "smtp.emailarchitect.net"

    ' If you don't have SMTP server, use the following codes to send email via DNS lookup 
    ' It is not recommended, most email providers would reject the email for anti-spam policy
    ' oSmtp.ServerAddr = ""   

    ' User and password for ESMTP authentication
    oSmtp.UserName = "test@emailarchitect.net"
    oSmtp.Password = "test"

    ' ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically
    oSmtp.ConnectType = ConnectTryTLS

    ' If your server uses 587 port 
    ' oSmtp.ServerPort = 587

    ' If your server uses 465 port with SSL/TLS 
    ' oSmtp.ConnectType = ConnectSSLAuto 
    ' oSmtp.ServerPort = 465

    ' If your server uses 25/587 port with SSL/TLS 
    ' oSmtp.ConnectType = ConnectSSLAuto 
    ' oSmtp.ServerPort = 587
   
    oSmtp.FromAddr = "test@adminsystem.net"
    oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0

    oSmtp.BodyFormat = 1
    oSmtp.Subject = "Test"
    oSmtp.BodyText = "<html>..<body>Hello, this is a test...."
    oSmtp.AltBody = "Hello, this is a test"

    If oSmtp.SendMail() = 0 Then
        MsgBox "Message delivered!"
    Else
        MsgBox oSmtp.GetLastErrDescription()
    End If
End Sub


[Visual C++ - Send Email with Alternative Body] #include "stdafx.h" #include <tchar.h> #include <Windows.h> #include "EASendMailObj.tlh" using namespace EASendMailObjLib; const int ConnectNormal = 0; const int ConnectSSLAuto = 1; const int ConnectSTARTTLS = 2; const int ConnectDirectSSL = 3; const int ConnectTryTLS = 4; void SendEmail() { ::CoInitialize(NULL); IMailPtr oSmtp = NULL; oSmtp.CreateInstance(__uuidof(EASendMailObjLib::Mail)); // for evaluation usage, please use "TryIt" as the license code. oSmtp->LicenseCode = _T("TryIt"); // Your SMTP server address oSmtp->ServerAddr = _T("smtp.emailarchitect.net"); // User and password for ESMTP authentication oSmtp->UserName = _T("test@emailarchitect.net"); oSmtp->Password = _T("test"); // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp->ConnectType = ConnectTryTLS; // If your server uses 587 port // oSmtp->ServerPort = 587; // If your server uses 465 port with SSL/TLS // oSmtp->ConnectType = ConnectSSLAuto; // oSmtp->ServerPort = 465; // If your server uses 25/587 port with SSL/TLS // oSmtp->ConnectType = ConnectSSLAuto; // oSmtp->ServerPort = 587; oSmtp->FromAddr = _T("test@emailarchitect.net"); oSmtp->AddRecipient(_T("Support Team"), _T("support@adminsystem.net"), 0); oSmtp->BodyFormat = 1; oSmtp->Subject = _T("Test"); oSmtp->BodyText = _T("<html>..<body>Hello, this is a test...."); oSmtp->AltBody = _T("Hello, this is a test"); if (oSmtp->SendMail() == 0) _tprintf(_T("Message delivered!")); else _tprintf((const TCHAR*)oSmtp->GetLastErrDescription()); }

See Also

BodyText Property
BodyFormat Property