problems with large email database

Giganews Newsgroups
Subject: problems with large email database
Posted by:  John Evans (johneva…@clear-Advantage.co.uk)
Date: Thu, 17 May 2007

Dear all,
            I have an email creation program that has worked well for years.
The client has recently grown his database of email recipients to over
12,000 and the program now falls over after 1000 - 2000 emails. It fails
both on his server and mine. The record reached is not relevant. It takes
around an hour to run a test so it is difficult to gather much information.
My thoughts are either an error talking to SMTP (but why after 1000
emails?), or a cummulative error (memory??). Any advice is greatly
appreciated.

When the program fails, it simply stops, I can scroll up and down database
records in the app, and change form pages, but cannot close the application,
I need to kill it. Is it still trying to connect to the smtp service, or in
some loop, or unable to free itself?

I looked at the code from the article by Zarko Gajic, my code is almost
identical.

Here is the (abridged) bit where I suspect there is a problem.

while not query.eof do
begin
//  build the email using text from a TpsHTMLEdit component (where the email
content is created),
// and add the email To: address from the query record

          mailsender.Username := datamodform.qparamsmailuser.AsString;
          mailsender.Password := datamodform.qparamsmailpass.AsString;
          mailsender.Host := datamodform.qparamsmailhost.AsString;
          try
            mailsender.Connect;  //mailsender is IdSMTP
            mailsender.Send(email);
          finally
            mailsender.Disconnect;
          end;

// some other stuff
  query.next;
end;

The other possible problem area is in the message create.
I cover different types of email, but use Tidtext.create each time.  This is
never "freed" and I am sure it happens automatically, can you confirm?

              email.Subject:=edAnalysisSubject.Text;
              memo1.clear;
              if emailimagelist.Count=0 then  // a string list containing
references to any images
              begin
                with Tidtext.Create(email.MessageParts, memo1.lines) do
                begin
                  ContentType := 'text/html';
                  Body.Text := emailtext.Text;
                end;
              end else
              begin
                with Tidtext.Create(email.MessageParts, memo1.lines) do
                begin
                  ContentType := 'text/plain';
                  Body.Text := emailtext.Text;
                end;
                with TIdtext.Create(email.MessageParts, nil) do
                begin
                  Body.Text:=changeimagetag(emailtext.text);
                  ContentType := 'text/html';
                end;
                buildimageintoemail;
              end;

kind regards

John Evans

Replies