Z
zepplin79
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> StatusMemo.Clear;<br> MailMessage.Clear;<br> //设置SMTP<br> SMTP.Host := HostEdit.Text;<br> SMTP.Port := 25;<br> SMTP.AuthenticationType :=atLogin;<br> SMTP.Username := UserNameEdit.Text;<br> SMTP.Password := PwdEdit.Text;<br> //设置邮件内容<br> MailMessage.From.Text := FromEdit.Text;<br> MailMessage.Recipients.EMailAddresses := ToEdit.Text;<br> MailMessage.Subject := SubjectEdit.Text;<br> MailMessage.Body.Assign(BodyMemo.Lines);<br><br> if FileExists(Attachment.Text) then<br> TIdAttachment.Create(MailMessage.MessageParts,Attachment.Text);<br><br> try<br> SMTP.Connect;<br> try<br> SMTP.Send(MailMessage);<br> ShowMessage('E-Mail 已寄出');<br> finally<br> if SMTP.Connected then<br> SMTP.Disconnect;<br> end;<br> except<br> on e: exception do<br> begin<br> ShowMessage('Mail 寄送失敗:' + e.Message);<br> end;<br> end;<br><br>我单步跟踪了一下,SMTP服务器已经连上了,就是SMTP.send方法返回错误了,这是什么问题???