Hello, I've still or even worse trouble with this e-mail sending. maybe I should explain it more in detail what my environment is and what I want to do.
Okay I have this: COM Client -> COM-Server -> ICS SmtpClient | Other application connected via TWSocket (TCP) The com server provides 3 functions for sending e-mails, one is used internally triggered by certain events sent by the other application. The two methods for sending e-mails (one for a testmail for testing the connection) the other for sending something specific shall send the e-mail and return whether this was successfull or not. If the sending takes more that a certain time it shall be aborted and counted as unsuccessfull. Sending is done in a loop over a list possibly containing more that one e-mail server address to that if the first fails the second will be tried etc. After the connect I've this here: t:=GetTickCount; while ((isemail_connection = true) and (mailerror = 0)) and (((GettickCount >= t) and (GetTickCount-t < timeout)) xor ((GettickCount < t) and (t-GetTickCount < timeout))) do begin sleep(10); Application.ProcessMessages; end; if (mailerror <> 0) or (isemail_connection = true) then begin try datenmodul.SmtpCli.CtrlSocket.Close; except end; end else begin try if datenmodul.SmtpCli.Connected then datenmodul.SmtpCli.Quit; except end; It shall wait for either the timeout or the finish of the e-mail sending process. In the OnRequestDone I've nearly 100% identical code to your mail sending excample (the all in one demo) except that the screen output is missing, the case is put into a try/except and the 10004 error won't lead to a abort of the eventhandler. The handler will set the isemail_connection flag when the quit stage is arrived and will set mailerror to the errorcode and leave the handler if there is some error. I also want the com server to handle the communication to that other program (not it's client) and process (at least partially) the data he gets from it. Unfortunatelly he can raise the event which also triggers a mail sending operation. And then I think the trouble starts. I've implemented there another loop which waits if a mail is currently sent on either the completion (because the same function and thus SmtpClient instance) will be user or a timeout. The waiting loop is similar to the one above. If the mailserver can be reached, all seems to be well, but if I give a non reachable one it miserably fails and the COM-server starts to do weired things! Have you any hints for me? I want the mailing to be partially blocking to be able to handle the other communication but timely tell the user whether seinding was ok or not. And what happens if sending takes place and the program get's closed? Greetings Markus -- 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