Connection closed gracefully

Giganews Newsgroups
Subject: Connection closed gracefully
Posted by:  Angelo Mangiaracina (angelo.mangiaraci…@gmail.com)
Date: Tue, 14 Jul 2009

Hi, I gave an application written in Delphi 2007 and Indy 10, that automate the mail sending to a selevted range of customers from a database.
The sending is done filling a the bcc list until he reach a predefined maximum than send the message abd continue with the rmaining selected customers, and so on

Now, running the program, at an undetermined moment, I reach a connection closed hracefully exception, That in my code should be handled.
inspecting the sending results, seem that only a part of selected customers has received the mail.

But if I update the databse to set for all customers the same mail of test, than the exception is no more raised and seems that all mails are corrected delivered.

This is the code that I use for sendind:

  procedure SendMailMessage;
  begin
      if not SMTP.Connected then
//      SMTP.Connect(1000);
        SMTP.Connect;
      try
        try
            SMTP.Send(MailMsg);
            Application.ProcessMessages;
            sleep(500);
        except
            on E: Exception do;
//              if not (E is EIdConnClosedGracefully) then
//                  raise
        end
      finally
        if SMTP.Connected then
            SMTP.Disconnect(false);
        MailMsg.BccList.Clear;
//        MailMsg.Body.Text := MsgText;
      end;
  end;

I also handle the onReceitError evenet of the SMTP component to tag customers that are in error during send.

Can You give me some idea to solve the problem?

Thank you Angelo

Replies