Re: [twsocket] Problems sending multiple E-Mails

2010-07-08 Thread Arno Garrels
Hello Stefan,

> I got now the message SMTP component not connected after sending ca.
> 380 Mails. Where can I handle the connection? Because I do an
> smtp.connect on every mail?!

Most likely you hit some server-side limit.
In OnRequestDone check for errors (Error = 0) and property Connected 
as well and do whatsoever is needed if something went wrong. 
The demos often do not include full error handling in order to keep
them small.

--
Arno Garrels   

--
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


Re: [twsocket] Problems sending multiple E-Mails

2010-07-08 Thread Stefan Göppert
Hi,

I got now the message SMTP component not connected after sending ca.
380 Mails. Where can I handle the connection? Because I do an
smtp.connect on every mail?!

Best regards,
Stefan




2010/7/7 Arno Garrels :
> Stefan Göppert wrote:
>
>> What do you mean with " ...post a
>> custom message and from its handler call sendMail." ?
>
> For example (untested):
>
> const
>    WM_SEND_DELAYED = WM_USER + 1;
>
> [..]
> type
>    TForm1 = class(TForm)
>    protected
>      procedure WmSendMailDelayed(var Msg: TMessage); message WM_SEND_DELAYED;
> [..]
>
> implemtation
>
> procedure TForm1.WmSendMailDelayed(var Msg: TMessage);
> begin
>  if Msg.WParam > -1 then
>    sendMail
>  else
>    ShowMessage('Done');
> end;
>
> Use it like:
>
> PostMessage(Form1.Handle, WM_SEND_DELAYED, whereIam, 0);
>
> --
> Arno Garrels
> --
> 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
>
--
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


Re: [twsocket] Problems sending multiple E-Mails

2010-07-07 Thread Stefan Göppert
Wow, thanks a lot. I try it out.

Best regards,
Stefan



2010/7/7 Arno Garrels :
> Stefan Göppert wrote:
>
>> What do you mean with " ...post a
>> custom message and from its handler call sendMail." ?
>
> For example (untested):
>
> const
>    WM_SEND_DELAYED = WM_USER + 1;
>
> [..]
> type
>    TForm1 = class(TForm)
>    protected
>      procedure WmSendMailDelayed(var Msg: TMessage); message WM_SEND_DELAYED;
> [..]
>
> implemtation
>
> procedure TForm1.WmSendMailDelayed(var Msg: TMessage);
> begin
>  if Msg.WParam > -1 then
>    sendMail
>  else
>    ShowMessage('Done');
> end;
>
> Use it like:
>
> PostMessage(Form1.Handle, WM_SEND_DELAYED, whereIam, 0);
>
> --
> Arno Garrels
> --
> 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
>



-- 
Stefan Göppert Softwareentwicklung
Nininghove 23
48653 Coesfeld / Deutschland
tel.: +49 / 02541 / 889100
fax: +49 / 02541 / 889101
mail: ste...@magicdesignssoftware.de
web: http://www.magicdesignssoftware.de
--
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


Re: [twsocket] Problems sending multiple E-Mails

2010-07-07 Thread Arno Garrels
Stefan Göppert wrote:

> What do you mean with " ...post a
> custom message and from its handler call sendMail." ?

For example (untested):

const
WM_SEND_DELAYED = WM_USER + 1;

[..]
type
TForm1 = class(TForm)
protected
  procedure WmSendMailDelayed(var Msg: TMessage); message WM_SEND_DELAYED;
[..]

implemtation

procedure TForm1.WmSendMailDelayed(var Msg: TMessage); 
begin
  if Msg.WParam > -1 then
sendMail
  else
ShowMessage('Done');
end;

Use it like:

PostMessage(Form1.Handle, WM_SEND_DELAYED, whereIam, 0); 

--
Arno Garrels
--
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


Re: [twsocket] Problems sending multiple E-Mails

2010-07-07 Thread Stefan Göppert
Hi,

and thanks for your fast reply. What do you mean with " ...post a
custom message and from its handler call sendMail." ?

Best regards,
Stefan



2010/7/7 Arno Garrels :
> Stefan Göppert wrote:
>> 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:
> [..]
>     smtpQuit     :  begin
> [..]
>>                     sleep(500);
>
> Do not call sleep, it's useless.
>
>>                     if whereIam > -1 then
>>                       sendMail(whereIam)
>
> Do not call sendMail here, instead post a custom message and
> from its handler call sendMail. In sendMail check whether
> the connection is closed, or handle event OnSessionClosed
> as well.
>
>>                     else
>>                       ShowMessage('ok');
>
> Do not call ShowMessage() from event handler, it processes
> messages which could lead to reentrance into the handler or to
> other unwanted results.
>
> --
> Arno Garrels
>
>
>
> --
> 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
--
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


Re: [twsocket] Problems sending multiple E-Mails

2010-07-07 Thread Arno Garrels
Stefan Göppert wrote:
> 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:
[..]
 smtpQuit :  begin
[..]
> sleep(500);

Do not call sleep, it's useless.

> if whereIam > -1 then
>   sendMail(whereIam)

Do not call sendMail here, instead post a custom message and
from its handler call sendMail. In sendMail check whether
the connection is closed, or handle event OnSessionClosed
as well.

> else
>   ShowMessage('ok');

Do not call ShowMessage() from event handler, it processes
messages which could lead to reentrance into the handler or to 
other unwanted results.

--
Arno Garrels



--
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


[twsocket] Problems sending multiple E-Mails

2010-07-07 Thread Stefan Göppert
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