Hi,

I try to send multiple E-Mails (single Mails, one after another). After a while 
(mostly if 380 E-Mails where send) I get an SMTP component not ready error. 
What can I do in this case?

Here some code:


procedure Tmail.SendMail(inVal : integer);
var
 stream: TStringStream;
 tmpname : string;
 k : integer;
 sl : TStringList;
begin
   if FRunning then exit;
   FRunning := True;
   try
     contentImages.Clear;
     smtp.PlainText.Clear;
     smtp.HtmlText.Clear;
     smtp.EmailImages.Clear;
     smtp.EmailFiles.Clear;
     mailcontent     := '';
     smtp.Host       := pref.ReadString('smtp','server','');
     smtp.Port       := pref.ReadString('smtp','port','');
     smtp.FromName   := pref.ReadString('smtp','mail','');
     smtp.HdrFrom    := pref.ReadString('smtp','mail','');
     smtp.Username   := pref.ReadString('smtp','user','');

     do connection settings and fill mail content ........................

     smtp.Connect
   except
     on E: Exception do
     begin
       MessageDlg(E.ClassName + ': ' + E.Message,mtError,[mbOK],0);
       FRunning := False;
     end;
   end;
end;


procedure Tmail.smtpRequestDone(Sender: TObject; RqType: TSmtpRequest;
 ErrorCode: Word);
begin

     ...............................

   smtpQuit     :  begin
                     HTMLStatusBar1.Panels[1].Progress.Position :=  0;
                     FRunning := False;
                     whereIam := whereIam-1;
                     HTMLStatusBar1.Panels[0].Text := IntToStr(whereIam+1);
                     sleep(500);
                     if whereIam > -1 then
                       sendMail(whereIam)
                     else
                       ShowMessage('ok');
                   end;
 end;
end;


Best regards,
Stefan



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to