BodyFormat Property


This property specifies current email body text format.

Data Type: Long

Set the property to one of the following values:

Value Meaning
0 text/plain (Default)
1 text/html

Examples

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

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

Private Sub Command1_Click()
    
    Dim oSmtp As New EASendMailObjLib.Mail
    oSmtp.LicenseCode = "TryIt"
    
    ' Your SMTP server address
    oSmtp.ServerAddr = "smtp.emailarchitect.net"

    ' 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

    ' Set your sender email address
    oSmtp.FromAddr = "test@emailarchitect.net"
    
    ' Add recipient email address
    oSmtp.AddRecipientEx "support@emailarchitect.net", 0
    
    ' Set email subject
    oSmtp.Subject = "test HTML email from VB 6.0 project"
    
    ' Set HTML body format
    oSmtp.BodyFormat = 1
    
    ' Set HTML body text
    oSmtp.BodyText = "<font size=5>This is</font> <font color=red><b>a test</b></font>"
    
    MsgBox "start to send email ..."

    If oSmtp.SendMail() = 0 Then
        MsgBox "email was sent successfully!"
    Else
        MsgBox "failed to send email with the following error:" & oSmtp.GetLastErrDescription()
    End If
    
End Sub


[Delphi - Send HTML Email] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, EASendMailObjLib_TLB; // add EASendMail unit type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; const ConnectNormal = 0; ConnectSSLAuto = 1; ConnectSTARTTLS = 2; ConnectDirectSSL = 3; ConnectTryTLS = 4; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var oSmtp : TMail; begin oSmtp := TMail.Create(Application); oSmtp.LicenseCode := 'TryIt'; // Your SMTP server address oSmtp.ServerAddr := 'smtp.emailarchitect.net'; // User and password for ESMTP authentication, oSmtp.UserName := 'test@emailarchitect.net'; oSmtp.Password := 'testpassword'; // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp.ConnectType := ConnectTryTLS; // Set your sender email address oSmtp.FromAddr := 'test@emailarchitect.net'; // Add recipient email address oSmtp.AddRecipientEx('support@emailarchitect.net', 0); // Set email subject oSmtp.Subject := 'test HTML email from Delphi project'; // Set HTML body format oSmtp.BodyFormat := 1; // Set HTML body text oSmtp.BodyText := '<font size=5>This is</font> <font color=red><b>a test</b></font>'; ShowMessage('start to send email ...'); if oSmtp.SendMail() = 0 then ShowMessage('email was sent successfully!') else ShowMessage('failed to send email with the following error: ' + oSmtp.GetLastErrDescription()); end; end.
[Visual C++ - Send HTML Email] #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; int _tmain(int argc, _TCHAR* argv[]) { ::CoInitialize(NULL); IMailPtr oSmtp = NULL; oSmtp.CreateInstance(__uuidof(EASendMailObjLib::Mail)); 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; // Set your sender email address oSmtp->FromAddr = _T("test@emailarchitect.net"); // Add recipient email address oSmtp->AddRecipientEx(_T("support@emailarchitect.net"), 0); // Set email subject oSmtp->Subject = _T("HTML email from Visual C++ project"); // Set HTML body format oSmtp->BodyFormat = 1; // Set HTML body text oSmtp->BodyText = _T("<font size=5>This is</font> <font color=red><b>a test</b></font>"); _tprintf(_T("Start to send HTML email ...\r\n")); if(oSmtp->SendMail() == 0) { _tprintf(_T("email was sent successfully!\r\n")); } else { _tprintf(_T("failed to send email with the following error: %s\r\n"), (const TCHAR*)oSmtp->GetLastErrDescription()); } return 0; }

See Also

BodyText Property
ImportMail Method
ImportMailEx Method
ImportHtml Method
ConvertHTML Method