!
procedure TForm1.btnSendClick(Sender: TObject);
begin
with IdSMTP1 do
begin
AuthenticationType:=atLogin;
Host:=edtHost.Text;
Username:=edtUserName.Text;
Password:=edtPassword.Text;
Port:=StrToInt(edtPort.Text);
try
Connected;
except
ShowMessage('连接失败!');
IdSMTP1.Free;
IdMessage1.Free;
Exit;
end;
end;
with IdMessage1 do
begin
From.Address:=edtFrom.Text;
Subject:=edtSubject.Text;
Recipients.EMailAddresses:=edtTo.Text;
Body.Clear;
Body.Text:=edtBody.Text;
end; try
IdSMTP1.Send(IdMessage1); //这里异常
ShowMessage('邮件发送成功!');
except
Application.MessageBox('邮件发送失败!!!','提示',MB_OK+MB_ICONERROR);
IdSMTP1.Free;
IdMessage1.Free;
Exit; end;
IdSMTP1.Free;
IdMessage1.Free;
end;
procedure TForm1.btnSendClick(Sender: TObject);
begin
with IdSMTP1 do
begin
AuthenticationType:=atLogin;
Host:=edtHost.Text;
Username:=edtUserName.Text;
Password:=edtPassword.Text;
Port:=StrToInt(edtPort.Text);
try
Connected;
except
ShowMessage('连接失败!');
IdSMTP1.Free;
IdMessage1.Free;
Exit;
end;
end;
with IdMessage1 do
begin
From.Address:=edtFrom.Text;
Subject:=edtSubject.Text;
Recipients.EMailAddresses:=edtTo.Text;
Body.Clear;
Body.Text:=edtBody.Text;
end; try
IdSMTP1.Send(IdMessage1); //这里异常
ShowMessage('邮件发送成功!');
except
Application.MessageBox('邮件发送失败!!!','提示',MB_OK+MB_ICONERROR);
IdSMTP1.Free;
IdMessage1.Free;
Exit; end;
IdSMTP1.Free;
IdMessage1.Free;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货