Delphi编写邮件发送程序
procedureTForm1.Button1Click(Sender:TObject);varfilename:String;begintryIdSMTP1.Disco...
procedure TForm1.Button1Click(Sender: TObject);
var
filename : String;
begin
try
IdSMTP1.Disconnect;
IdSMTP1.Host := edit1.Text;
IdSMTP1.AuthenticationType := atLogin; //保证登录模式为Login
IdSMTP1.Username := edit2.Text;
IdSMTP1.Password := edit3.Text;
filename := OpenDialog1.FileName ; //需要添加的附件文件
TIdAttachment.Create(IdMessage1.MessageParts,filename); //添加附件
IdMessage1.From.Address := edit4.Text;
IdMessage1.Recipients.EMailAddresses:=edit5.Text;
IdMessage1.Subject:= edit6.Text;
IdMessage1.Body.Text := Memo1.Text; //此处为邮件正文
IdMessage1.CharSet := 'gb2312'; //保证附件正文汉字的正常显示
IdMessage1.Body.Assign(Memo1.Lines);
if IdSMTP1.AuthSchemesSupported.IndexOf('LOGIN')>-1 then
begin
IdSMTP1.AuthenticationType := atLogin; //连接前要保存为Login 上面己设,此处不必要
IdSMTP1.Authenticate;
end;
IdSMTP1.Connect(); //连接SMTP服务器
IdSMTP1.Authenticate;
IdSMTP1.Send(IdMessage1); //向服务器发送邮箱
IdSMTP1.Disconnect; //断开与服务器的连接
finally;
IdSMTP1.Disconnect;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
OpenDialog1.Execute;
Label7.Caption:=OpenDialog1.FileName;
end;
然后老是会出现同一个错误:
Debugger Exception Notificatin
Project Project1.exe raised exception class EIdProtocloReplyError with message '用户被锁定'. Process stopped.Use step or Run to contnue.
为什么会这样呢?哪里出了毛病?怎么样修改?(主要是怎么样修改) 展开
var
filename : String;
begin
try
IdSMTP1.Disconnect;
IdSMTP1.Host := edit1.Text;
IdSMTP1.AuthenticationType := atLogin; //保证登录模式为Login
IdSMTP1.Username := edit2.Text;
IdSMTP1.Password := edit3.Text;
filename := OpenDialog1.FileName ; //需要添加的附件文件
TIdAttachment.Create(IdMessage1.MessageParts,filename); //添加附件
IdMessage1.From.Address := edit4.Text;
IdMessage1.Recipients.EMailAddresses:=edit5.Text;
IdMessage1.Subject:= edit6.Text;
IdMessage1.Body.Text := Memo1.Text; //此处为邮件正文
IdMessage1.CharSet := 'gb2312'; //保证附件正文汉字的正常显示
IdMessage1.Body.Assign(Memo1.Lines);
if IdSMTP1.AuthSchemesSupported.IndexOf('LOGIN')>-1 then
begin
IdSMTP1.AuthenticationType := atLogin; //连接前要保存为Login 上面己设,此处不必要
IdSMTP1.Authenticate;
end;
IdSMTP1.Connect(); //连接SMTP服务器
IdSMTP1.Authenticate;
IdSMTP1.Send(IdMessage1); //向服务器发送邮箱
IdSMTP1.Disconnect; //断开与服务器的连接
finally;
IdSMTP1.Disconnect;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
OpenDialog1.Execute;
Label7.Caption:=OpenDialog1.FileName;
end;
然后老是会出现同一个错误:
Debugger Exception Notificatin
Project Project1.exe raised exception class EIdProtocloReplyError with message '用户被锁定'. Process stopped.Use step or Run to contnue.
为什么会这样呢?哪里出了毛病?怎么样修改?(主要是怎么样修改) 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询