Difference between revisions of "TSmtpCli.OnRequestDone"
Jump to navigation
Jump to search
(One intermediate revision by one other user not shown) | |||
Line 9: | Line 9: | ||
== Description == | == Description == | ||
− | This event will fire when the server has sent a response | + | This event will fire when the server has sent a response to your request and all data transfers has been done. |
== Examples == | == Examples == | ||
Line 15: | Line 15: | ||
This is a sample of how to handle a common set of responses. LogMsg method is just a call to a procedure that output information visually in a memo. | This is a sample of how to handle a common set of responses. LogMsg method is just a call to a procedure that output information visually in a memo. | ||
+ | <syntaxhighlight lang="delphi"> | ||
if (error > 0) then | if (error > 0) then | ||
begin | begin | ||
Line 72: | Line 73: | ||
logMsg('SMTP connection closed'); | logMsg('SMTP connection closed'); | ||
end; | end; | ||
+ | </syntaxhighlight> | ||
+ | |||
== Best practices == | == Best practices == | ||
''nothing yet'' | ''nothing yet'' |
Latest revision as of 17:09, 1 July 2010
Main page -> ICS components reference -> TSmtpCli -> OnRequestDone
Definition
procedure (Sender: TObject; RqType: TSmtpRequest; ErrCode: Word) of object;
- Sender : the client which fired the event
- RqType : type of the request.
- ErrCode : error code for the request. If it is 0, there was no error.
Description
This event will fire when the server has sent a response to your request and all data transfers has been done.
Examples
This is a sample of how to handle a common set of responses. LogMsg method is just a call to a procedure that output information visually in a memo.
<syntaxhighlight lang="delphi">
if (error > 0) then begin logMsg('Service Error occured RqType:'+inttostr(integer(RqType))+' Error:'+vartostr(error)); Exit; end; if RqType = smtpConnect then begin logMsg('Sending HELO'); Smtp.Helo end else if RqType = smtpOpen then begin //open is easiest to use when you have the need for authentication logMsg('smtOpen, sending MailFrom'); Smtp.MailFrom; end else if RqType = smtpHelo then begin logMsg('Sending from'); Smtp.MailFrom; end else if RqType = smtpMailFrom then begin logMsg('Sending to'); Smtp.RcptTo; end else if RqType = smtpRcptTo then begin logMsg('Sending data'); Smtp.Data; end else if RqType = smtpData then begin //here you need to generate the e-mail, and trigger more... if SendEmailQryEMAILID.AsString <> then begin logMsg('Sending next email'); generateSingleEmail; //a procedure i use to create my e-mail Smtp.MailFrom; end else begin logMsg('No more email to send, quitting.'); Smtp.Quit end; end else if RqType = smtpQuit then begin logMsg('SMTP connection closed'); end;
</syntaxhighlight>
Best practices
nothing yet