Re: [twsocket] Html email to many users

2006-02-28 Thread Francois Piette
Have a look at MailSndAsync sample program (Delphi) delivered with ICS. It is 
mostly what you want
to do.

--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be


- Original Message - 
From: "Pawel (WP)" <[EMAIL PROTECTED]>
To: "ICS support mailing" 
Sent: Monday, February 27, 2006 9:08 PM
Subject: Re: [twsocket] Html email to many users


> Francois, You writed:
> "(...) Instead of programming a loop, you must use the event. You simply
> start your
> first mail send and then do nothing until the event signaling the end of
> request os done. Then only you pick the next mail from your list and send
> it.
> Using this scheme, you can go faster by user multiple component. Each one
> will send a mail without blocking the others (Note that some email servers
>  limit the number of concurrent connections, so you may want to use only one
>  component per destination server. Be clever !) (...)"
>
> Thanks for quick answer. But...
> What event I have to use? Could anybody write me this more clear? Can
> somebody correct my code?
> I am just begining with ICS...
> Best regards
>
> - Original Message - 
> From: "Francois PIETTE" <[EMAIL PROTECTED]>
> To: "ICS support mailing" 
> Sent: Monday, February 27, 2006 8:32 PM
> Subject: Re: [twsocket] Html email to many users
>
>
> >>  for i:= 0 to Lista.Count-1  do   // from 0 to 1
> >> begin
> >>   SendMail(Lista.Strings[i]);
> >> end;
> >> And - what am I doing wrong - this doesn't work. Sending email is like in
> >> demo program.
> >> I have message:
> >> SmtpException: SMTP component not ready
> >
> > Your problem is a classical one: Your are trying to use a non-blocking
> > event-driven component as a blocking one.
> > The component will send your email in the background while your program is
> > doing other things. Of course a single component can send only one mail at
> > a
> > time. When you do a loop, the first iteration start sending a mail. Then
> > second iteration would also send a mail while the previous is still
> > occuring
> > and therefore you get the "component busy" error.
> >
> > Instead of programming a loop, you must use the event. You simply start
> > your
> > first mail send and then do nothing until the event signaling the end of
> > request os done. Then only you pick the next mail from your list and send
> > it.
> >
> > Using this scheme, you can go faster by user multiple component. Each one
> > will send a mail without blocking the others (Note that some email servers
> > limit the number of concurrent connections, so you may want to use only
> > one
> > component per destination server. Be clever !).
> >
> > --
> > Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
> > --
> > [EMAIL PROTECTED]
> > http://www.overbyte.be
> >
> >
> > -- 
> > To unsubscribe or change your settings for TWSocket mailing list
> > please goto http://www.elists.org/mailman/listinfo/twsocket
> > Visit our website at http://www.overbyte.be
> >
> >
>
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be

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


Re: [twsocket] Html email to many users

2006-02-27 Thread Pawel (WP)
Francois, You writed:
"(...) Instead of programming a loop, you must use the event. You simply
start your
first mail send and then do nothing until the event signaling the end of
request os done. Then only you pick the next mail from your list and send
it.
Using this scheme, you can go faster by user multiple component. Each one
will send a mail without blocking the others (Note that some email servers
 limit the number of concurrent connections, so you may want to use only one
 component per destination server. Be clever !) (...)"

Thanks for quick answer. But...
What event I have to use? Could anybody write me this more clear? Can
somebody correct my code?
I am just begining with ICS...
Best regards

- Original Message - 
From: "Francois PIETTE" <[EMAIL PROTECTED]>
To: "ICS support mailing" 
Sent: Monday, February 27, 2006 8:32 PM
Subject: Re: [twsocket] Html email to many users


>>  for i:= 0 to Lista.Count-1  do   // from 0 to 1
>> begin
>>   SendMail(Lista.Strings[i]);
>> end;
>> And - what am I doing wrong - this doesn't work. Sending email is like in
>> demo program.
>> I have message:
>> SmtpException: SMTP component not ready
>
> Your problem is a classical one: Your are trying to use a non-blocking
> event-driven component as a blocking one.
> The component will send your email in the background while your program is
> doing other things. Of course a single component can send only one mail at 
> a
> time. When you do a loop, the first iteration start sending a mail. Then
> second iteration would also send a mail while the previous is still 
> occuring
> and therefore you get the "component busy" error.
>
> Instead of programming a loop, you must use the event. You simply start 
> your
> first mail send and then do nothing until the event signaling the end of
> request os done. Then only you pick the next mail from your list and send
> it.
>
> Using this scheme, you can go faster by user multiple component. Each one
> will send a mail without blocking the others (Note that some email servers
> limit the number of concurrent connections, so you may want to use only 
> one
> component per destination server. Be clever !).
>
> --
> Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
> --
> [EMAIL PROTECTED]
> http://www.overbyte.be
>
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>
> 


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


Re: [twsocket] Html email to many users

2006-02-27 Thread Francois PIETTE
>  for i:= 0 to Lista.Count-1  do   // from 0 to 1
> begin
>   SendMail(Lista.Strings[i]);
> end;
> And - what am I doing wrong - this doesn't work. Sending email is like in 
> demo program.
> I have message:
> SmtpException: SMTP component not ready

Your problem is a classical one: Your are trying to use a non-blocking 
event-driven component as a blocking one.
The component will send your email in the background while your program is 
doing other things. Of course a single component can send only one mail at a 
time. When you do a loop, the first iteration start sending a mail. Then 
second iteration would also send a mail while the previous is still occuring 
and therefore you get the "component busy" error.

Instead of programming a loop, you must use the event. You simply start your 
first mail send and then do nothing until the event signaling the end of 
request os done. Then only you pick the next mail from your list and send 
it.

Using this scheme, you can go faster by user multiple component. Each one 
will send a mail without blocking the others (Note that some email servers 
limit the number of concurrent connections, so you may want to use only one 
component per destination server. Be clever !).

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


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


[twsocket] Html email to many users

2006-02-27 Thread WP
Hi
I have another problem, I hope the last one.
My email have to be send to many people, for example to 150.
I know that some servers have limit for recipients for one email. 
So, I have written procedure that divide this 150 people for 100 and 50.
So, first mail will be send to 100 people and the rest, 50 will be send in 
second email.

This users (recipients) are in TStringList. (Lista)
like this:
..
Lista.Strings[0]);  --> [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL 
PROTECTED];   // in first mail n=100
Lista.Strings[1]);  --> [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL 
PROTECTED];   // in second mail n=50

I have Button - in OnClick I have procedure : "Send"

This "Send" procedure is:

procedure Send;
var
..
begin
   Lista:=TStringList.Create;
   ...
//code to create Lista with lines of adress (each lines have max 100 adresses)
...
 // now, I Am sending email in the loop - in our case it will be done 2 times


//**
  for i:= 0 to Lista.Count-1  do   // from 0 to 1
 begin
   SendMail(Lista.Strings[i]);
 end;
//**   // it is not 
working


   end;
   finally
   Lista.Free;
   end;
end;

and the last is:
procedure SendMail(Adresses : string);
FRunning := TRUE;
try
  HtmlSmtpClient.PlainText:= nil;
  HtmlSmtpClient.HtmlText:= EmailBody;
  HtmlSmtpClient.EmailImages.Clear;
  HtmlSmtpClient.EmailImages.Add(ObrazekMaila1);
  HtmlSmtpClient.EmailImages.Add(ObrazekMaila2);
  HtmlSmtpClient.Host:= SmtpServerName;
  HtmlSmtpClient.Port:= IntToStr(SmtpServerPort);
  HtmlSmtpClient.FromName:=UserName + ' <'+UserEmail+'>';
  HtmlSmtpClient.HdrSubject:=TematWiadomosciE.Text;

  case SmtpAuthType of
0: HtmlSmtpClient.AuthType:= smtpAuthNone;
1: HtmlSmtpClient.AuthType:= smtpAuthLogin;
  end;

  if SmtpServerPassword<>'' then
begin
   HtmlSmtpClient.Password:=SmtpServerPassword; //passwordedit.Text;
end else
begin
   HtmlSmtpClient.Password:=InputBox('Podaj hasło do serwera 
SMTP','Hasło:','');
end;

  if SmtpServerUser<>'' then
begin
   HtmlSmtpClient.Username:=SmtpServerUser;
end else
begin
   HtmlSmtpClient.Username:=InputBox('Podaj login do serwera 
SMTP','Login:','');
end;
  HtmlSmtpClient.RcptName.Clear;
  HtmlSmtpClient.RcptNameAdd('', '', Adresses);

  Display('Łączenie z serwerem SMTP ('+ SmtpServerName +')...');
  HtmlSmtpClient.Connect;
except
on E:Exception do
  begin
 Display(E.ClassName + ': ' + E.Message);
 FRunning := FALSE;
  end;
end;



And - what am I doing wrong - this doesn't work. Sending email is like in demo 
program.
I have message:
Łączenie z serwerem SMTP (SmtpServerName)...
Łączenie z serwerem SMTP (SmtpServerName)...   // from SendMail procedure
SmtpException: SMTP component not ready

So, how can I do this correct? How to know, that sending first mail to 100 
people are done, that I can send seconf mail? 
I think, that component is trying to send two emails in the same time... but i 
think that after sending first mail component (TSMTPHtmlClient) should 
disconnect and connect again. I didn't found Disconnect method... 

Please help me
Thanks in advance
Ps: I hope that You understand what I mean... sending one message to many 
people in the same time
Paweł Porwisz
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be