[twsocket] How to send multiple email with SMTPClient

Wilfried Mestdagh wilfried_sonal@compuserve.com
Sat, 10 Jun 2000 22:21:52 +0200


Dennis,

Use OnRequestDone event for your next mail. Ust TTimer for timeout and in
OnTimer check state of your program/smtpclient. I have no time at moment to
see for example but search for 'Stephen Williams' in message digest for
similar examples how to use this event / components.

rgds, Wilfried

> -----Original Message-----
> From: twsocket-admin@elists.org
> [mailto:twsocket-admin@elists.org]On Behalf Of Dennis Poon
> Sent: donderdag 1 juni 2000 15:25
> To: twsocket@elists.org
> Subject: Re: [twsocket] How to send multiple email with SMTPClient
>
>
>
> Thanks for your code but like you said, you code does not handle the case
> when SMTP.Open fail to connect to smtp server which is the problem I have.
> I have a time out feature in my original code but it is a simple look with
> Application.ProcessMessage.  I need an improvement over it (e.g. using
> thread  or Timer or Idle Process) so that it will continue to
> execute after
> I cann connect and send mail.
>
> Anyone can help?
>
> Dennis
> ----- Original Message -----
> From: Grant Black <grant.black@smartmove.co.nz>
> To: <twsocket@elists.org>
> Sent: Thursday, June 01, 2000 5:59 AM
> Subject: RE: [twsocket] How to send multiple email with SMTPClient
>
>
> > See my sample application (HTMLMail) on the user made pages -
> it can send
> a
> > series of e-mails via SMTP.
> >
> > User made page: http://users.swing.be/francois.piette/usermadeuk.htm
> >
> >
> > > -----Original Message-----
> > > From: Dennis Poon [mailto:pmh@netvigator.com]
> > > Sent: Thursday, 1 June 2000 05:36
> > > To: twsocket@elists.org
> > > Subject: [twsocket] How to send multiple email with SMTPClient
> > >
> > >
> > > I am using the SMTPClient component to send email and I wrote
> > > the following
> > > unit to encapsulate a function
> > > procedure SendICSEmail(SMTPServer : string; Tos : array of
> > > string; From,
> > > Subject, Body: string);
> > >
> > > to do that.
> > >
> > > I am wonder if there is a better way to send multiple emails
> > > (I currently
> > > keep on Applicatin.processMessages until the SMTPClient is ready again
> > > before I send a second email).  However, if the machine is no
> > > online, or
> > > some other reasons, it will take forever to become ready so I
> > > put a check in
> > > time to abort it.
> > >
> > > Is there a property to check within SMTPClient to see if it
> > > has already
> > > failed to connect or send.  that way, I don't have to wait
> > > until it is too
> > > long.
> > >
> > > Thanks.
> > >
> > > Dennis
> > > -----
> > > unit ICSSendMail;
> > > interface
> > > uses SMTPProt;
> > > procedure SendICSEmail(SMTPServer : string; Tos : array of
> > > string; From,
> > > Subject, Body: string);
> > >
> > > implementation
> > > uses SysUtils,Forms;
> > > var
> > >   SMTPClient : TSMTPCli;
> > >
> > > procedure SendICSEmail(SMTPServer : string; Tos : array of
> > > string; From,
> > > Subject, Body: string);
> > > var i : integer;
> > >     StartTime : TDateTime;
> > > begin
> > >     SmtpClient.Host := SMTPServer;
> > >     SmtpClient.Port := 'smtp';
> > >     if Not SMTPClient.Connected then begin
> > >        SmtpClient.Connect;
> > >        StartTime := now();
> > >        while Not SmtpClient.Connected do begin
> > >          Application.ProcessMessages;
> > >          if (Now()-StartTime) > 0.1/24/60 then begin
> > >             raise Exception.Create('SMTP Connection fails
> > > within reasonable
> > > time');
> > >          end;
> > >        end;
> > >
> > >        StartTime := now();
> > >        while Not (SmtpClient.State in [smtpReady]) do begin
> > >          Application.ProcessMessages;
> > >          if (Now()-StartTime) > 0.1/24/60 then begin
> > >             raise Exception.Create('SMTP not ready within
> > > reasonable time');
> > >          end;
> > >        end;
> > >        SMTPClient.Helo;
> > >     end;
> > >
> > >     StartTime := now();
> > >     while Not (SmtpClient.State in [smtpReady]) do begin
> > >       Application.ProcessMessages;
> > >       if (Now()-StartTime) > 0.5/24/60 then begin
> > >          raise Exception.Create('SMTP not ready within
> > > reasonable time');
> > >       end;
> > >     end;
> > >
> > >
> > >     SmtpClient.RcptName.Clear;
> > >     for i := low(Tos) to High(Tos) do begin
> > >       SmtpClient.RcptName.Add(Tos[i]);
> > >     end;
> > >
> > >     SmtpClient.HdrFrom         := From;
> > >     SmtpClient.HdrTo           := '';
> > >     SmtpClient.HdrSubject      := Subject;
> > >     SmtpClient.SignOn          := 'Signature';
> > >     SmtpClient.FromName        := From;
> > >     SmtpClient.MailMessage.Clear;
> > >     SmtpClient.MailMessage.Text := Body;
> > > //    SmtpClient.EmailFiles      := FileAttachMemo.Lines;
> > >     SmtpClient.Mail;
> > > end;
> > >
> > > initialization
> > >
> > >   SMTPClient := TSMTPCli.Create(nil);
> > >
> > > finalization
> > >
> > >   SMTPClient.Free;
> > >
> > > end.
> > >
> > >
> > > _______________________________________________
> > > TWSocket mailing list [http://elists.org/mailman/listinfo/twsocket]
> > > Visit our website at http://www.rtfm.be/fpiette/indexuk.htm
> > >
> >
> > _______________________________________________
> > TWSocket mailing list [http://elists.org/mailman/listinfo/twsocket]
> > Visit our website at http://www.rtfm.be/fpiette/indexuk.htm
>
>
> _______________________________________________
> TWSocket mailing list [http://elists.org/mailman/listinfo/twsocket]
> Visit our website at http://www.rtfm.be/fpiette/indexuk.htm