delphi自带的程序中就有例程,你可以看delphi/demo/fastnet/
procedure TForm1.Button7Click(Sender: TObject);
begin
NMSMTP1.ExpandList(Edit11.Text);
end;
procedure TForm1.NMSMTP1MailListReturn(MailAddress: String);
begin
Memo2.Lines.Add(MailAddress);
end;
procedure TForm1.NMSMTP1ConnectionFailed(Sender: TObject);
begin
ShowMessage('Connection Failed');
end;
procedure TForm1.NMSMTP1ConnectionRequired(var handled: Boolean);
begin
If MessageDlg('Connection Required. Connect?', mtConfirmation, mbOkCancel, 0) = mrOk then
Begin
Handled := TRUE;
NMSMTP1.Connect;
End;
end;
procedure TForm1.NMSMTP1Failure(Sender: TObject);
begin
StatusBar1.SimpleText := 'Failure';
end;
procedure TForm1.NMSMTP1HostResolved(Sender: TComponent);
begin
StatusBar1.SimpleText := 'Host Resolved';
end;
procedure TForm1.NMSMTP1InvalidHost(var handled: Boolean);
var
TmpStr: String;
begin
If InputQuery('Invalid Host!', 'Specify a new host:', TmpStr) then
Begin
NMSMTP1.Host := TmpStr;
Handled := TRUE;
End;
end;
procedure TForm1.NMSMTP1PacketSent(Sender: TObject);
begin
StatusBar1.SimpleText := IntToStr(NMSMTP1.BytesSent)+' bytes of '+IntToStr(NMSMTP1.BytesTotal)+' sent';
end;