How can I abort the SMTP send operation using Synapse for Delphi?

I am currently testing Ararat Synapse to send email to Delphi.

The local function creates TSMTPSend and sends an email.
How can I abort this operation? I installed the callback function assigned by SMTP.Sock.OnStatus to execute some status output.
When I want to interrupt the sending process, I thought that I could use TTCPBlockSocket TSMTPSend in the callback function, because in this function I do not have direct access to TSMTPSend directly.

What I wanted to do looks basically like

MyCallBack(Sender: TObject; Reason: THookSocketReason; const Value: string);
begin
  if FCancelWasClicked then
  begin
    if Sender is TTCPBlockSocket then
      TTCPBlockSocket(Sender).StopFlag := True;
      // or TTCPBlockSocket(Sender).AbortSocket or CloseSocket
  end;
end;

StopFlag , AbortSocket/CloseSocket StackOverFlow, HR_CloseSocket .

? ?

+5
1

Synapse heartbeat, Cancel.

http://www.ararat.cz/synapse/doku.php/public:howto:heartbeat

OnHeartbeat, HeartbeatRate StopFlag .

+6

All Articles