关于indy控件的奇怪问题,我可是模仿demo写的程序呀.奇怪......(100分)

  • 主题发起人 主题发起人 laofuzi
  • 开始时间 开始时间
L

laofuzi

Unregistered / Unconfirmed
GUEST, unregistred user!
我用的是indy控件中的idsmtp和idmessage想实现smtp发信,结果不行,我可是完全模仿的demo中的例子呀.请各位大虾指点.我把源程序贴在下面.(一定给分!!!!!!!!!)
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP;

type
TForm1 = class(TForm)
smtp: TIdSMTP;
mail: TIdMessage;
Label1: TLabel;
edtHost: TEdit;
Label2: TLabel;
edtUser: TEdit;
Label3: TLabel;
edtPassword: TEdit;
Label4: TLabel;
edtPort: TEdit;
Label5: TLabel;
edtTo: TEdit;
Label6: TLabel;
edtSubject: TEdit;
Label7: TLabel;
edtFrom: TEdit;
memBody: TMemo;
Label8: TLabel;
Button1: TButton;
chkSmtp: TCheckBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
mail.Body.Assign(memBody.Lines);
mail.From.Text:=edtFrom.Text ;
mail.ReplyTo.EMailAddresses :=edtFrom.Text ;
mail.Subject :=edtSubject.Text ;
if chkSmtp.Checked then
smtp.AuthenticationType :=atLogin
else
smtp.AuthenticationType :=atNone;
smtp.Username :=edtUser.Text ;
smtp.Password :=edtPassword.Text ;
smtp.Host :=edtHost.Text ;
smtp.Port :=StrToInt(edtPort.text);
smtp.Connect ;
try
smtp.Send(mail);
finally
smtp.Disconnect ;
end;
end;

end.

运行后总是出现503error:need RCPT command;
请问如何解决?急......
 
怎么搞的,没有人会吗?
 
以下是我自已写的,没有一点问题,你可以对比一下。
unit smtpprg;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, IdMessage,IdStackConsts;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit4: TEdit;
Panel1: TPanel;
Edit5: TEdit;
Edit6: TEdit;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Memo1: TMemo;
Button1: TButton;
IdSMTP1: TIdSMTP;
CheckBox1: TCheckBox;
Memo2: TMemo;
Button2: TButton;
IdMessage1: TIdMessage;
procedure Button1Click(Sender: TObject);
procedure IdSMTP1Connected(Sender: TObject);
procedure IdSMTP1Status(axSender: TObject; const axStatus: TIdStatus;
const asStatusText: String);
procedure IdSMTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure IdSMTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdSMTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
if checkbox1.Checked then IdSMTP1.AuthenticationType := atLogin
else IdSMTP1.AuthenticationType := atNone;
IdSMTP1.Host:=edit1.Text;
IdSMTP1.Port:=25;
IdSMTP1.UserId:=edit2.Text;
IdSMTP1.Password:=edit3.Text;

IdSMTP1.Connect;
with IdMessage1 do
begin
body.Clear;
Body.Add(memo1.Lines.Text);//内容
From.Text := edit6.Text;
Recipients.EMailAddresses :=edit4.Text;//收件人
Subject:=edit5.Text;//主题

end;
IdSMTP1.Send(IdMessage1);
IdSmtp1.Disconnect;



end;

procedure TForm1.IdSMTP1Connected(Sender: TObject);
begin
memo2.Lines.Add('已经连接到服务器');
//IdMessage1.Body:=memo2.Lines;
end;

procedure TForm1.IdSMTP1Status(axSender: TObject;
const axStatus: TIdStatus; const asStatusText: String);
begin
memo2.Lines.Add(asStatusText);
end;

procedure TForm1.IdSMTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
memo2.Lines.Add(inttostr(AWorkCount));
end;

procedure TForm1.IdSMTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
memo2.Lines.Add(inttostr(AWorkCountMax));
end;

procedure TForm1.IdSMTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
Memo2.Lines.Add('end');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
IdSMTP1.Disconnect;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin

end;

end.
 
这是我用的代码,邮件可以发送出去,但是接收时却无法收到具体的内容,其它
的,但我用FoxMail却能收到,我该如何收呢?但FoxMail收的时候却只把它当成
纯文本而不是HTML文档,怎么办?
With IDSMTP1 do
begin
Host:='127.0.0.1';
Port:=25;
Connect;
IDMessage1.From.Address:='yanghaijun@zjz.com';
IDMessage1.From.Name:='yanghaijun';
IDMessage1.Recipients.EMailAddresses:='you@zjz.com';
IDMessage1.Subject:='test';

tls:=TStringList.Create;
tls.Add('<HTML><Head><Title>test</Title>');
tls.Add('</Head><Body BGColor="#00CCFF">');
tls.Add('Hello!</BODY></HTML>');
IDMessage1.Body.Clear;
IDMessage1.Body.Add(tls.text);
Send(IDMessage1);
tls.Free;
Disconnect;
end;
 
你的邮箱支持SMTP吗
 
请教 一下怎么带 附件啊???
谢谢你们!!!
我很急啊
找不到是用哪个属性!!!!
谢谢!!
 
后退
顶部