For forums, blogs and more please visit our
Developer Tools Community.
By: David Intersimone
Abstract: EMail Blasting with Borland Delphi 4.
Wednesday, October 28, 1998
Scotts Valley, California
EMail Blasting with Borland Delphi 4.
If you attended our conference this year in Denver,
you probably received at least one email blast from me.
The email message was sent by an application that uses Delphi 4's SMTP component (check
out the Internet palette page). The Email Blaster Souffle application becomes the third addition to my "Betty Hacker's Down
Home Developer's Cookbook" (the first recipe was
Internet Browser, the second recipe was Red Hot
Salsa Drawings with Autocad R14). You can find an index of other
souffle recipes on the web.
I do not like spam, neither Hormel SPAM nor the email kind.
When I use my email blaster it is only to
friends, family, partners and conference attendees who want to receive the messages. The
Inprise listservers only send email messages
to those who sign up for specific products. We should all do everything we
can to Fight Spam on the Internet.
To add to your own cookbook just cut and paste the recipe included
below. Zip files containing the source code, form files, and sample
database table are available
for Delphi and
Betty Hacker's Quick 'n Easy
Email Blaster Souffle
To create the best Email Blaster Souffle you need to start with the choicest ingredients.
With Borland Delphi 4 and the SMTP component you can create your own email blaster program.
Preheat your PC to 110 volts (220 volts for most developers outside the US).
To your hard drive bowl...
Mix in Delphi 4
Combine ingredients and bake the Email Blaster Souffle application.
Sift and combine the ingredients for the Email Blaster Souffle: Select File | New Application.
Roll out the form's caption: Set the Form's caption property to Email Blaster
or your own caption text to taste.
Fold in a Data Module: Select File | New... and chose a Data Module from the new items page.
Measure in a Data Source: Add a Table and Datasource component to the Data Module. Set the DatabaseName to an alias that points to
your database that contains email addresses (I used the alias - Email). Set the TableName property to the email address table
(my Paradox table is named Email.db).
Chop in an SMTP component: From the Delphi 4 Internet component palette, drop the NMSMTP component on to your main form. This
is the component that will let you send mail via a pop mail server.
Stir in a Menu component: From the Standard component palette, drop down a Menu component. Plug in the captions for
several menu items including: File, Exit, MailServer, Database, Blast, and Help. See form for other menu items.
Pour in a StatusBar component: From the Win32 component palette, drop down a StatusBar component. Set the SimplePanel property
to True. This lets you use ths status bar as a place to display text messages. Use code in event handlers like the following to
display status information: StatusBar1.SimpleText := 'Packet Sent';
Blend in event handlers for Menu and SMTP components: Event handlers for the SMTP component let you keep track of the status
of server connections and message send status. The event handlers for the Menu component let you connect to the PopMail server,
open the database, start and stop the email blast.
The StartBlast menu item event handler is where all the processing is done. The code is as follows.
procedure TBlastForm.Start1Click(Sender: TObject);
Start1.Enabled := false;
Stop1.Enabled := true;
BlastLabel.Caption := 'Blasting!';
Blasting := true;
while (not DM.EmailTable.Eof) and Blasting do begin
// wait for completion of sendmail
while SendingMail and Blasting do
// let the application process messages while we wait
// refreshes the contents of the memo component
Blasting := false;
Start1.Enabled := true;
Stop1.Enabled := false;
BlastLabel.Caption := 'No Blast';
The OnCreate event handler for the form looks for a text file, Message.txt, that contains the message to send. OnCreate also opens a text file that will be used as
a log of what happened during the blaster session.
procedure TBlastForm.FormCreate(Sender: TObject);
I : integer;
SendingMail := false;
// open message.txt file and load into a memo field
MessageText := TStringList.Create;
// open log file for output
Writeln(LogFile, '[ Start of Blast Log File ]');
Writeln(LogFile, '< Blast Message Text >');
for I := 0 to MessageText.Count - 1 do
Writeln(LogFile, '< Log of Email Messages Sent >');
FillMemo is a method I use to create the body of the message to be send. You can use this method to add to the
message at runtime. In this example I only add today's date and a personal greeting to the text from the Message.txt file.
MessageMemo.Lines.Add(FormatDateTime('mmmm dd, yyyy',Now));
SendIt is the method where I use the SMTP component to send the message via the Mail Server. Notice that I
check to see if I have a valid email address (one that contains an @ sign in the text). My main form
contains text fields where the subject for the message (MessageSubject.Text), the sender's email address(FromEmailAddress.Text),
and the sender's name (MesageFrom.Text).
if Pos('@',DM.EmailTableEMail.Value) > 0 then begin
SendingMail := true;
// text string of senders email address
NMSMTP1.PostMessage.FromAddress := FromEmailAddress.Text;
NMSMTP1.PostMessage.FromName := MessageFrom.Text; // name of sender
// email address from database
NMSMTP1.PostMessage.Subject := MessageSubject.Text; // subject text
// lines for the message body
NMSMTP1.PostMessage.LocalProgram := 'EmailBlast';
Writeln(LogFile, '+ message sent: '
+DM.EmailTableFIRSTNAME.Value+' '+DM.EmailTableLASTNAME.Value+' '
Writeln(LogFile, '- invalid/no email address: '
+DM.EmailTableFIRSTNAME.Value+' '+DM.EmailTableLASTNAME.Value+' '
Bake for approximately 3-5 seconds or until the Souffle has risen and the top is golden brown.
Bake (hit the F9 key) for approximately 3-5 seconds or until the Souffle has risen and the top is golder brown.
Serve with the sauce and beverage of your choice.
When the Email Blaster Souffle is running, type in the IP address of your Pop Mail Server, Chose the MailServer | Connect
menu item, and chose the Database | Open Database menu item. You are now ready to start mail blasting. You can also use
the DBNavigator to edit, insert, and delete email database entries. To start the email blast, choose the
Blast Start menu item. If you follow the instructions carefully you
should see the following result on your screen.
One Email Blaster Souffle application per developer.
You can do the same thing with C++Builder 3.
Could not retrieve comments. Please try again later.
Download Delphi 10 now!
Webinars on demand!
More social media choices:
Delphi on Google+
@RADTools on Twitter
Server Response from: ETNASC03