暗黑3暗影套地下城:如何使用indy9发邮件,望举例,谢谢!

来源:百度文库 编辑:高考问答 时间:2024/04/29 04:34:24
求助!!急!!!
我用的是Indy9(Delphi7),调试程序时不知为什么出错,出错信息是:

Acess violation at adress 00414F64 in module 'Project.EXE'.Read of adress FFFFFFFF.

出错段:
procedure TProject.SendClick(Sender: TObject);
var Msg:TIdMessage;
begin
Msg.Clear;
Msg.Body.Append(edit1.Text);
Msg.Body.Append(edit2.Text);
Msg.From.Text:='Pass@God.com';
Msg.Subject:=edit1.Text;
SMTP.AuthenticationType:=atLogin;
SMTP.Host:='163.com';
SMTP.Username:='well';
SMTP.Password:='well';
SMTP.Port := 25;
SMTP.Connect;
SMTP.Send(Msg);
SMTP.Disconnect;
Msg.Free;
end;

还望高手相助!

在接口处引用IdMessageClient和IdMessage单元

procedure TProject.SendClick(Sender: TObject);
var Msg:TIdMessage;
begin
Msg:=TIdMessage.Create(self); //加上这一句就OK
Msg.Clear;
Msg.Body.Append(edit1.Text);
Msg.Body.Append(edit2.Text);
Msg.From.Text:='Pass@God.com';
Msg.Subject:=edit1.Text;
SMTP.AuthenticationType:=atLogin;
SMTP.Host:='163.com';
SMTP.Username:='well';
SMTP.Password:='well';
SMTP.Port := 25;
SMTP.Connect;
SMTP.Send(Msg);
SMTP.Disconnect;
Msg.Free;
end;