Greets All,

I need to loop thru a database and process several emails.  I first setup the 
default settings for the SmtpCli component, then later in my code I loop thru 
data in a dataset as shown below.  My problem is it will only process the first 
email in the dataset, then when it gets to the "Connect" command a second time 
I get an error: 'SMTP component not ready'.  What did I forget to do or do 
wrong?

Here is my code:
      with dtmProcessEmails.cdsEmail do
        begin
          First;

          while not EOF do
            begin
              with dtmProcessEmails.SmtpCli do
                begin
                  FromName := dtmProcessEmails.cdsEmailEMAIL_FROM.AsString; // 
Actual from email address
                  HdrFrom := recUser.CompanyName;
                  HdrTo := dtmProcessEmails.cdsEmailEMAIL_TO.AsString;
                  HdrReplyTo := '[EMAIL PROTECTED]'; 
                  HdrSubject := dtmProcessEmails.cdsEmailEMAIL_SUBJECT.AsString;

                  //* Recipient list is computed from To, Cc and Bcc fields
                  RcptName.Clear;
                  RcptNameAdd(dtmProcessEmails.cdsEmailEMAIL_TO.AsString, '', 
'');

                  Display('Connecting to SMTP server...');

                  { Start first operation to do to send an email          }
                  { Next operations are started from OnRequestDone event  }
                  Connect;
                end;

              barProgressBar.IncPartsByOne;

              Next;
            end;
        end;
-- 
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