主题:麻烦解决一个问题,为什么会出现这样的对话框
xtlxbb
[专家分:80] 发布于 2006-06-12 11:47:00
[img]d:\1.bmp[/img]
回复列表 (共2个回复)
沙发
hanwb2002 [专家分:1340] 发布于 2006-06-13 11:50:00
看不见
板凳
xtlxbb [专家分:80] 发布于 2006-06-13 18:03:00
我用的是idsmtp及idmessage组件,写了如下程序,正常编译后,出现了上述对话框.源程序如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, StdCtrls;
type
TForm1 = class(TForm)
edtfrom: TEdit;
edtusername: TEdit;
edtpsw: TEdit;
edtto: TEdit;
edtsubject: TEdit;
edthost: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
edtattach: TEdit;
memcoment: TMemo;
Label8: TLabel;
Button1: TButton;
Button2: TButton;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if opendialog1.execute then
self.edtattach.text:=opendialog1.FileName
else
begin
self.edtattach.text:='';
showmessage('没有附件');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
self.IdMessage1.Clear;
self.IdMessage1.From.text:=edtfrom.text;
self.IdMessage1.Recipients.EMailAddresses:=edtto.text;
self.idMessage1.body.assign(memcoment.lines);
self.idMessage1.subject:=edtsubject.text;
if edtattach.text<>'' then
tidattachment.create(idmessage1.messageparts,edtattach.text);
self.idSMTP1.authenticationtype:=atlogin;
self.idSMTP1.username:=edtusername.text;
self.idSMTP1.password:=edtpsw.text;
self.idSMTP1.host:=edthost.text;
try
self.idsmtp1.connect();
try
self.idsmtp1.send(idmessage1);
showmessage('e-mail已经到达');
finally
self.idsmtp1.disconnect;
end;
except
on e:exception do
begin
showmessage('e-mail发送失败;'+E.Message);
end;
end;
end;
end.
我来回复