为什么不能发送邮件提示:‘bad sequence of commands’
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP;type
TForm1 = class(TForm)
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
idmessage1.Clear;
idmessage1.Subject:='daring';
idmessage1.Body.Add('test');
//idmessage1.From.Text:='[email protected]';
idmessage1.From.Address:='[email protected]';
//idmessage1.From.Name:='[email protected]';
idmessage1.Recipients.EMailAddresses:='[email protected]';
//idmessage1.ReceiptRecipient.Text:='';
idsmtp1.Host:='smtp.126.com';
idsmtp1.AuthenticationType:=atLogin;
idsmtp1.Username:='daring';
idsmtp1.Password:='*****';//邮箱密码
idsmtp1.Port:=25;
try
idsmtp1.Connect();
idsmtp1.Send(idmessage1);
showmessage('OK!');
except
showmessage('无法连接到服务器!');
exit;
end;
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP;type
TForm1 = class(TForm)
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
idmessage1.Clear;
idmessage1.Subject:='daring';
idmessage1.Body.Add('test');
//idmessage1.From.Text:='[email protected]';
idmessage1.From.Address:='[email protected]';
//idmessage1.From.Name:='[email protected]';
idmessage1.Recipients.EMailAddresses:='[email protected]';
//idmessage1.ReceiptRecipient.Text:='';
idsmtp1.Host:='smtp.126.com';
idsmtp1.AuthenticationType:=atLogin;
idsmtp1.Username:='daring';
idsmtp1.Password:='*****';//邮箱密码
idsmtp1.Port:=25;
try
idsmtp1.Connect();
idsmtp1.Send(idmessage1);
showmessage('OK!');
except
showmessage('无法连接到服务器!');
exit;
end;
end;end.
解决方案 »
- VirtualProtect内存分配访问无效。
- Delphi2009/C++Builder2009新特性
- 烦请 使用installshield的朋友帮帮忙。
- 问一个觉得很难的问题。。请高手进来帮忙解决!(开贴100分,不够可以再加)
- 怎样才能让Help & Manual编译后的文件支持中文显示?解决了,再开贴给200分。
- 登录窗体
- DLL_PROCESS_DETACH的问题
- 请问用编写SQL查询语句,怎么样用参数?
- 我在安装ORACLE8时提示要加大虚存,不知加C还是D?多大值?请告之详细步骤,谢谢!
- 关于DELPHI调用WEBSERVICE时,调试正常,正常执行报错!
- 请教一下radiogroup的横排问题,注意了我知道设置columns属性!
- 如何用delphi远程连接sql server,给出代码
idsmtp1.Authenticate;
idsmtp1.Send(idmessage1); //试试
还是错误,提示为:error:authentication failed
idsmtp1.Authenticate;