|
Download ActiveEmail SMTP/POP3 Toolkit 3.1  (4431 KB - .exe file)
Download Manual  (190 KB - .htm file)
Using ActiveEmail SMTP/POP3 Toolkit with Borland Delphi
ActiveEmail SMTP/POP3 Toolkit is a software development kit (SDK) that enables the user to send (SMTP) and receive (POP3) e-mail messages.
ActiveEmail supports SMTP, POP3, multiple recipients (To, CC, BCC), multiple attachments (ASCII and binary),
rich text body formats (RTF/HTML), Unicode, multiple character sets, SMTP authorization (AUTH PLAIN, AUTH LOGIN, AUTH CRAM MD5),
POP3 authorization (Plain, APOP), POP3 header download, different character sets (including arabic, chinese, japanese, russian, greek and many more),
different encodings (including 7/8 bit, quoted-printable, base64).
ActiveEmail can be well integrated into Borland Delphi environments.
This document describes how ActiveEmail can be integrated into Borland Delphi projects.
Step 1: Download and install ActiveEmail
Download the ActiveEmail SMTP/POP3 Toolkit from the ActiveXperts Download Site and start the installation.
The installation guides you through the installation process.
Step 2: Create a new Delphi Project
Launch Borland Delphi (for instance 'Delphi 2005') from the Start menu.
Choose 'New' from the 'File' menu and select your preferred kind of application, for instance: 'VCL Forms Application - Delphi for Win32'.
A new Form is displayed in the workspace.

(Click on the picture to enlarge)
Step 3: Refer to the ActiveEmail Library and create the objects
Now that a new project has been created, you must add a reference to ActiveEmail in the project to be able to use the ActiveEmail objects.
To do so, choose 'Import Component...' from the 'Component' menu. The Import Components' dialog appears. Select 'Import a Type Library':

(Click on the picture to enlarge)
In the 'Registered Type Libraries' page, select 'ActiveEmail 3.0 Type Library' and click 'Next':

(Click on the picture to enlarge)
In the 'Components' page, leave all fields default and click 'Next':

(Click on the picture to enlarge)
In the 'Install' page, select 'Create Unit' and click 'Next':

(Click on the picture to enlarge)
The interface code is generated now and is shown in the AEMAILLib_TBL tab of the project.
Step 4: Declare and create the object
From the Project Manager, open Unit1.bas and add the AEMAILLib_TLB to the 'Uses' statement to refer to the ActiveEmail library:

(Click on the picture to enlarge)
In the 'private' or 'public' section, declare the follwoing objects for SMTP:
objSmtpServer : ISmtpServer;
objSmtpMail : ISmtpMail;
In the same section, declare the following objects for POP3:
objPop3Server : IPop3Server;
objPop3Mail : IPop3Mail;
Also, declare the e-mail constants object:
objConstants : IEmailConstants
You can now create the objects, for insntance in the 'FormCreate' function:
objSmtpServer := TSmtpServer.Create( Application ).DefaultInterface;
objSmtpMail := TSmtpMail.Create( Application ).DefaultInterface;
objPop3Server := TPop3Server.Create( Application ).DefaultInterface;
objConstants := TEmailConstants.Create( Application ).DefaultInterface;
Step 5: Send and/or receive an e-mail messages
You can now send and/or receive e-mail messages.
The following code shows how to send an e-mail message:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellAPI, Registry, AEMAILLib_TLB;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
editServer: TEdit;
checkAuth: TCheckBox;
Label2: TLabel;
Label3: TLabel;
editPassword: TEdit;
Label4: TLabel;
Label5: TLabel;
editFromName: TEdit;
editFromAddress: TEdit;
Label6: TLabel;
GroupBox2: TGroupBox;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label11: TLabel;
editMailTo: TEdit;
editSubject: TEdit;
editBody: TEdit;
comboEncoding: TComboBox;
Label12: TLabel;
comboFormat: TComboBox;
Label13: TLabel;
comboPriority: TComboBox;
buttonSend: TButton;
GroupBox3: TGroupBox;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
editResult: TEdit;
editLogfile: TEdit;
editAccount: TEdit;
buttonView: TButton;
editResponse: TMemo;
Label17: TLabel;
procedure buttonSendClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure buttonViewClick(Sender: TObject);
function GetResult : Integer;
procedure LoadSettings ();
procedure SaveSettings ();
procedure FormClose(Sender: TObject; var Action: TCloseAction);
function GetTempDirectory: string;
procedure checkAuthClick(Sender: TObject);
private
{ Private declarations }
objSmtpServer : ISmtpServer;
objSmtpMail : ISmtpMail;
objSmtpConst : IEmailConstants;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.buttonSendClick(Sender: TObject);
var vtVar : OleVariant;
begin
objSmtpServer.LogFile := editLogfile.Text;
if checkAuth.Checked = true then begin
objSmtpServer.Connect(editServer.Text, editAccount.Text, editPassword.Text);
end
else
begin
objSmtpServer.Connect ( editServer.Text , '', '' );
end;
if GetResult = 0 then begin
objSmtpMail.Clear ();
objSmtpMail.Subject := editSubject.Text;
objSmtpMail.Body := editBody.Text;
objSmtpMail.FromName := editFromName.Text;
objSmtpMail.FromAddress := editFromAddress.Text;
objSmtpMail.AddTo( editFromAddress.Text, editFromName.Text);
objSmtpMail.BodyType := comboFormat.ItemIndex;
objSmtpMail.Priority := comboPriority.ItemIndex + 1;
if comboEncoding.ItemIndex = 1 then objSmtpMail.Encoding := objSmtpConst.asMESSAGE_ENCODING_UTF8
else objSmtpMail.Encoding:= objSmtpConst.asMESSAGE_ENCODING_DEFAULT;
vtVar := objSmtpMail;
objSmtpServer.Send ( vtVar );
GetResult;
objSmtpServer.Disconnect();
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
objSmtpMail := TSmtpMail.Create(Application).DefaultInterface;
objSmtpServer := TSmtpServer.Create(Application).DefaultInterface;
objSmtpConst := TEmailConstants.Create(Application).DefaultInterface;
LoadSettings ();
comboFormat.Items.Add('Plain');
comboFormat.Items.Add('HTML');
comboFormat.ItemIndex := 0;
comboPriority.Items.Add ('Lowest');
comboPriority.Items.Add ('Low');
comboPriority.Items.Add('Medium');
comboPriority.Items.Add('High');
comboPriority.Items.Add('Highest');
comboPriority.ItemIndex := 2;
comboEncoding.Items.Add ('Default');
comboEncoding.Items.Add( 'UTF-8');
comboEncoding.ItemIndex := 0;
GetTempDirectory ();
end;
function TForm1.GetTempDirectory: string;
var Buffer: array[0..MAX_PATH] of Char;
begin
GetTempPath(SizeOf(Buffer) - 1, Buffer);
editLogfile.Text := StrPas(Buffer) + 'SmtpLog.txt';
end;
function TForm1.GetResult : Integer;
begin
Result := objSmtpServer.LastError;
editResult.Text := 'ERROR ' + IntToStr ( Result ) + ' : ' + objSmtpServer.GetErrorDescription( Result );
editResponse.Text := objSmtpServer.LastSmtpResponse;
end;
procedure TForm1.buttonViewClick(Sender: TObject);
var LogFile : PAnsiChar;
begin
LogFile := StrNew(PChar(editLogfile.Text));
ShellExecute ( 0, 'open' , LogFile, '', '', SW_SHOW )
end;
procedure TForm1.LoadSettings ();
var reg : TRegistry;
begin
reg := TRegistry.Create(KEY_READ);
reg.OpenKey( 'SOFTWARE\ActiveXperts\SMTP', true);
editServer.Text := reg.ReadString( 'Server' );
editAccount.Text := reg.ReadString('Account');
editPassword.Text := reg.ReadString('Password');
editFromAddress.Text := reg.ReadString('FromAddress');
editFromName.Text := reg.ReadString('FromName');
editMailTo.Text := reg.ReadString('ToAddress');
end;
procedure TForm1.SaveSettings ();
var reg : TRegistry;
begin
reg := TRegistry.Create (KEY_WRITE);
reg.OpenKey ('SOFTWARE\ActiveXperts\SMTP', true );
reg.WriteString('Server',editServer.Text);
reg.WriteString('Account',editAccount.Text );
reg.WriteString('Password',editPassword.Text);
reg.WriteString('FromAddress',editFromAddress.Text );
reg.WriteString('ToAddress',editMailTo.Text );
reg.WriteString('FromName',editFromName.Text);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SaveSettings ();
end;
procedure TForm1.checkAuthClick(Sender: TObject);
begin
editAccount.Enabled := checkAuth.Checked;
editPassword.Enabled := checkAuth.Checked;
end;
end.
There are many working samples included with the product.
You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/activemail.
NOTE: Demo Projects are created with Borland Delphi 7
The ActiveEmail project ships with a set of samples for Borland Delphi.
The projects are created with Borland Delphi 7.
Users with a later version of Borland Delphi 7 can open such a project. The Borland Conversion Wizard will guide you through the process of converting the project to the version used.
ActiveEmail is a SMTP- and POP3 development component (SDK). This control can be used by any Windows development platform,
including Visual Basic .NET, Visual CSharp .NET,
ASP .NET (VB,CS),
ASP,
Visual Basic,
Visual Studio/Visual C++,
Delphi,
PHP,
HTML,
VBScript and any other ActiveX/COM compliant platform. ActiveEmail is an ActiveXperts Software B.V. Product.
|
|