BodyText Property


This property specifies current email body text.

Data Type: String

Remarks

Specify the main body text of email message.

Email body text is formatted according to the setting of BodyFormat property.

To facilitate addition of large amounts of text to the message, you may use ImportMail() method. This method fills BodyText property with content from specified file.

Examples

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

[VB6, VBA - Send HTML Email]
Private Sub Command1_Click()
    
    Dim oSmtp As New EASendMailObjLib.Mail
    oSmtp.LicenseCode = "TryIt"
    
    ' 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>"
    
    ' Your SMTP server address
    oSmtp.ServerAddr = "smtp.emailarchitect.net"
    
    ' User and password for ESMTP authentication, if your server doesn't require
    ' User authentication, please remove the following codes.
    oSmtp.UserName = "test@emailarchitect.net"
    oSmtp.Password = "testpassword"

    ' If your smtp server requires SSL connection, please add this line
    ' oSmtp.SSL_init
    
    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;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  oSmtp : TMail;
begin
  oSmtp := TMail.Create(Application);
  oSmtp.LicenseCode := 'TryIt';

  // 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>';

  // Your SMTP server address
  oSmtp.ServerAddr := 'smtp.emailarchitect.net';

  // User and password for ESMTP authentication, if your server doesn't require
  // user authentication, please remove the following codes
  oSmtp.UserName := 'test@emailarchitect.net';
  oSmtp.Password := 'testpassword';

  // If your SMTP server requires SSL connection, please add this line
  // oSmtp.SSL_init();

  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 "easendmailobj.tlh"
using namespace EASendMailObjLib;

int _tmain(int argc, _TCHAR* argv[])
{
    ::CoInitialize( NULL );

    IMailPtr oSmtp = NULL;
    oSmtp.CreateInstance( __uuidof(EASendMailObjLib::Mail));
    oSmtp->LicenseCode = _T("TryIt");
    
    // 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>");

    // Your SMTP server address
    oSmtp->ServerAddr = _T("smtp.emailarchitect.net");
    
    // User and password for ESMTP authentication, if your server doesn't 
    // require User authentication, please remove the following codes.
    oSmtp->UserName = _T("test@emailarchitect.net");
    oSmtp->Password = _T("testpassword");

    // If your SMTP server requires SSL connection, please add this line
    // oSmtp->SSL_init();

    _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());
    }

    if( oSmtp != NULL )
        oSmtp.Release();

    return 0;
}

See Also

AltBody Property
BodyFormat Property
Charset Property
ImportMail Method
ImportMailEx Method
ImportHtml Method
ConvertHTML Method

Online Examples

VB6, VBA - Send HTML Email with Embedded Images
Delphi - Send HTML Email with Embedded Images
Visual C++ - HTML Send Email with Embedded Images