delphi关于邮箱收信的问题


delphi关于邮箱收信的问题

unit Unit1;

interface

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

type
TForm1 = class(TForm)
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Edit6: TEdit;
procedure IdSMTP1Connected(Sender: TObject);
procedure IdSMTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdSMTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
procedure IdSMTP1Disconnected(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.IdSMTP1Connected(Sender: TObject);
begin
showmessage('服务器连接成功!');
end;

procedure TForm1.IdSMTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
Showmessage('开始发信');
end;

procedure TForm1.IdSMTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
showmessage('发信完毕');
end;

procedure TForm1.IdSMTP1Disconnected(Sender: TObject);
begin
showmessage('连接断开');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
idmessage1.From.Address := edit1.Text;
idmessage1.Subject := edit2.text;
idmessage1.Body.Assign(memo1.Lines);
idmessage1.Recipients.EMailAddresses := edit6.Text;
idsmtp1.Host := edit3.Text;
idsmtp1.Port := 25;
idsmtp1.Username :=edit5.Text;
idsmtp1.Password := edit4.Text;
idsmtp1.Connect();
idsmtp1.AuthenticationType := atlogin;
idsmtp1.Send(idmessage1);
end;

end.
联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678