Hi Angus. > > The component will use any SMTP server you specify, although you'll > usually need authentication for any SMTP other than that of your ISP. > > Angus
I set the Host to be smtp.xyz.com, AuthType: SMTPAuthLogin, then call Connect(). The password is set later, which is wrong, but when I set it before Connect(), it would not connect. Below is the skeleton of my code. How and where must I include authentication, using Auth(), I presume? Thanks. Raymond procedure TSendEmailForm.SendEmailButtonClick(Sender: TObject); procedure DefineConnectionFields(); begin with SMTPClient do begin Host := 'smtp.xyz.com'; Port := '587'; end; end; procedure SetHdrDetails(); begin with TSMTPCli(Sender) do begin HdrFrom := FEmailFrom; Password := FPassword; end; end; begin DefineConnectionFields(); SetHdrDetails(); SMTPClient.Connect(); end; procedure TSendEmailForm.SMTPClientRequestDone(Sender: TObject; RqType: TSmtpRequest; ErrorCode: Word); procedure SetRecipientAndMessage(); begin with TSMTPCli(Sender) do begin HdrTo := CustomerName + ' <' + CustomerEmail + '>'; HdrCC := FEmailCC; HdrSubject := FSubject; with MailMessage do begin Clear(); AddStrings(MessageMemo.Lines); end; EMailFiles := nil; end; {with} end; begin if Error = 0 then begin case RqType of smtpConnect: begin with TSMTPCli(Sender) do begin SignOn := 'Raymond'; Helo(); end; end; smtpHelo: begin with TSMTPCli(Sender) do begin FromName := FEmailFrom; MailFrom(); end; end; smtpMailFrom: begin if RecipientIndex < RecipientsRE.Lines.Count then begin with TSMTPCli(Sender) do begin with RcptName do begin Clear(); Add(Trim(Copy(RecipientsRE.Lines[RecipientIndex], 36, Length(RecipientsRE.Lines[RecipientIndex])))); Inc(RecipientIndex); end; RcptTo(); end; end else // no more recipients begin TSMTPCli(Sender).Quit(); end; end; smtpRcptTo: begin SetRecipientAndMessage(); TSMTPCli(Sender).Data(); end; smtpData: begin TSMTPCli(Sender).MailFrom(); end; smtpQuit: begin {$IFDEF TESTING} MessageDlg('Message sent to customer(s).', mtInformation, [mbOK], 0); {$ENDIF} end; end; {case} end else // Error <> 0 begin MessageDlg( 'Request: ' + #9 + IntToStr(Ord(RqType)) + CL2 + 'Error: ' + #9 + WSocketErrorDesc(Error), mtError, [mbOK], 0); end; end; -- 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