我没有做过,但是很有兴趣.
如果愿意,给我来信[email protected]

解决方案 »

  1.   

    我没有做过,但是很有兴趣.
    如果愿意,给我来信[email protected]
      

  2.   

    delphi的demos里有例子
    unit smtpdem;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ComCtrls, StdCtrls, Psock, NMsmtp, ExtCtrls;type
      TForm1 = class(TForm)
        PageControl1: TPageControl;
        TabSheet1: TTabSheet;
        TabSheet2: TTabSheet;
        TabSheet3: TTabSheet;
        Edit1: TEdit;
        NMSMTP1: TNMSMTP;
        Label1: TLabel;
        Edit2: TEdit;
        Label2: TLabel;
        Button1: TButton;
        Button2: TButton;
        TabSheet4: TTabSheet;
        StatusBar1: TStatusBar;
        Edit3: TEdit;
        Label3: TLabel;
        Button3: TButton;
        Edit4: TEdit;
        Label4: TLabel;
        Memo1: TMemo;
        Panel1: TPanel;
        GroupBox1: TGroupBox;
        Edit5: TEdit;
        Edit6: TEdit;
        Label5: TLabel;
        Label6: TLabel;
        Edit7: TEdit;
        Label7: TLabel;
        Edit8: TEdit;
        Label8: TLabel;
        Edit9: TEdit;
        Label9: TLabel;
        ListBox1: TListBox;
        Label10: TLabel;
        Button4: TButton;
        Button5: TButton;
        Memo2: TMemo;
        Panel2: TPanel;
        Button6: TButton;
        Label11: TLabel;
        Panel3: TPanel;
        Label14: TLabel;
        Button7: TButton;
        Label12: TLabel;
        OpenDialog1: TOpenDialog;
        Edit10: TEdit;
        Edit11: TEdit;
        procedure Button1Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure NMSMTP1Connect(Sender: TObject);
        procedure NMSMTP1Disconnect(Sender: TObject);
        procedure NMSMTP1Status(Sender: TComponent; Status: String);
        procedure Button4Click(Sender: TObject);
        procedure Button5Click(Sender: TObject);
        procedure Button6Click(Sender: TObject);
        procedure NMSMTP1EncodeStart(Filename: String);
        procedure NMSMTP1EncodeEnd(Filename: String);
        procedure Button7Click(Sender: TObject);
        procedure NMSMTP1MailListReturn(MailAddress: String);
        procedure NMSMTP1ConnectionFailed(Sender: TObject);
        procedure NMSMTP1ConnectionRequired(var handled: Boolean);
        procedure NMSMTP1Failure(Sender: TObject);
        procedure NMSMTP1HostResolved(Sender: TComponent);
        procedure NMSMTP1InvalidHost(var handled: Boolean);
        procedure NMSMTP1PacketSent(Sender: TObject);
        procedure NMSMTP1RecipientNotFound(Recipient: String);
        procedure NMSMTP1SendStart(Sender: TObject);
        procedure NMSMTP1Success(Sender: TObject);
        procedure NMSMTP1HeaderIncomplete(var handled: Boolean;
          hiType: Integer);
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    begin
      NMSMTP1.Host := Edit1.Text;
      NMSMTP1.Port := StrToInt(Edit2.Text);
      NMSMTP1.UserID := Edit4.Text;
      NMSMTP1.Connect;
    end;procedure TForm1.Button3Click(Sender: TObject);
    var
      TmpStr: String;
    begin
      TmpStr := Edit3.Text; // Do this so the user can't change the edit box.
      If NMSMTP1.Verify(TmpStr) then
        ShowMessage(TmpStr+' verified')
      else
        ShowMessage(TmpStr+' not verified');
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      NMSMTP1.Disconnect;
    end;procedure TForm1.NMSMTP1Connect(Sender: TObject);
    begin
      StatusBar1.SimpleText := 'Connected';
    end;procedure TForm1.NMSMTP1Disconnect(Sender: TObject);
    begin
      If StatusBar1 <> nil then
        StatusBar1.SimpleText := 'Disconnected';
    end;procedure TForm1.NMSMTP1Status(Sender: TComponent; Status: String);
    begin
      If StatusBar1 <> nil then
        StatusBar1.SimpleText := status;
    end;procedure TForm1.Button4Click(Sender: TObject);
    begin
      If OpenDialog1.Execute then
        ListBox1.Items.Add(OpenDialog1.FileName);
    end;procedure TForm1.Button5Click(Sender: TObject);
    begin
      ListBox1.Items.Delete(ListBox1.ItemIndex);
    end;procedure TForm1.Button6Click(Sender: TObject);
    begin
      NMSMTP1.PostMessage.FromAddress := Edit6.Text;
      NMSMTP1.PostMessage.FromName := Edit5.Text;
      NMSMTP1.PostMessage.Subject := Edit10.Text;
      NMSMTP1.PostMessage.ToAddress.Add(Edit7.Text);
      NMSMTP1.PostMessage.ToBlindCarbonCopy.Add(Edit9.Text);
      NMSMTP1.PostMessage.ToCarbonCopy.Add(Edit8.Text);
      NMSMTP1.PostMessage.Attachments.AddStrings(Listbox1.Items);
      NMSMTP1.PostMessage.Body.Assign(Memo1.Lines);
      NMSMTP1.SendMail;
    end;procedure TForm1.NMSMTP1EncodeStart(Filename: String);
    begin
      StatusBar1.SimpleText := 'Encoding '+Filename;
    end;procedure TForm1.NMSMTP1EncodeEnd(Filename: String);
    begin
      StatusBar1.SimpleText := 'Finished encoding '+Filename;
    end;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;procedure TForm1.NMSMTP1RecipientNotFound(Recipient: String);
    begin
      ShowMessage('Recipient "'+Recipient+'" not found');
    end;procedure TForm1.NMSMTP1SendStart(Sender: TObject);
    begin
      StatusBar1.simpleText := 'Sending message';
    end;procedure TForm1.NMSMTP1Success(Sender: TObject);
    begin
      StatusBar1.SimpleText := 'Success';
    end;procedure TForm1.NMSMTP1HeaderIncomplete(var handled: Boolean;
      hiType: Integer);
    begin
      ShowMessage('Header Incomplete.');
    end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
     NMSMTP1.Abort;
    end;end.
      

  3.   

    coolmail很好用,可以先取邮件头再取邮件
      

  4.   

    我用过,不过还是尽量不要用Delphi提供的这些组件。
    听一个高手网友说有个WinShoes组件包挺好。
      

  5.   

    to williamGui:
      为什么你建议不用这些控件?
      winshoes组件为什么好,哪里获得,怎样用呢?
      

  6.   

    不要用Delphi里提供的控件,对OutLook的支持不好
    用SakMail
      

  7.   

    呵呵,D5的fastnet控件中的SMTP很好用的,CSDN的自动mail发送程序就是用的这个
    按照D5的DEMO改改就行了
      

  8.   

    qdshen:SakMail 哪里有下载? 
      

  9.   

    我有一个例子(网上的):
    --------------------------------------------------------------------------------
    利用Delphi编程发送E-mailhttp://www.wapsec.com.cn/delphi(2000年11月24日)  作者:钱可栋 
    --------------------------------------------------------------------------------
     
      接发E-mail是许多“网虫”必修的功课,E-mail工具软件也很多,国外 
    的有Microsoft的Outlook Express、The Bat等,国内则有FoxMail这样的精品。 
    其实,利用可视化编程工具Delphi4.0也能够制作出自己的E-mail软件。 
      Delphi4.0有关E-mail的组件有两个:NmPOP3和NmSTMP,它们都位于Internet 
    选项卡上,其中,NmPOP3组件封装并实现POP3协议,用来从Internet POP3服务 
    器上读取电子邮件;NmSTMP封装并实现STMP协议,可用来向Internet的STMP服 
    务器发送电子邮件。限于篇幅,我们不能两者都介绍,这里只用NmSTMP编写一 
    个发送E-mail的程序,至于NmPOP3,以后有机会再谈,或者在看完本文后你有 
    兴趣,也可以借助于Delphi的帮助文档尝试用NmPOP3编程。 
      我们先来看一下程序运行界面。图1是程序主窗体,上面有一个字符串网格 
    (StringGrid)和三个按钮,它们的容器是仅有一个标签的PageControl。单击 
    “Clear”钮清除网格内容,单击“Send”钮发送E-mail,单击“New Mail” 
    钮弹出图2所示的对话框,此对话框用来设置STMP服务器名称、发件人地址、收 
    件人地址、发件人名称和邮件主题,其中前三项必须填写,“Select File”按 
    钮用来打开Open对话框,以便选取要发送的附件。 
      NmSTMP的属性和方法不多,关键的属性是Host(STMP服务器名称)和PostMessage 
    (包含邮件信息),正确设置了Host属性和PostMessage属性后,就可以用Connect 
    方法(连接服务器)和SendMail方法发送E-mail了。 
      编写代码之前先要改变StringGrid1的一些缺省属性:ColCount属性为6, 
    FixedCols属性为0,RowCount属性为2,另外,将PageControl1的Align属性置 
    为alClient。 
      以下是Unit1(主窗体)代码清单: 
      unit Unit1; 
      interface 
      uses 
       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 
    Dialogs, Grids, ComCtrls, StdCtrls, Psock, NMsmtp; 
      type 
       TForm1 = class(TForm) 
       PageControl1: TPageControl; 
       TabSheet1: TTabSheet; 
       StatusBar1: TStatusBar; 
       StringGrid1: TStringGrid; 
       Button1: TButton; 
       Button2: TButton; 
       Button3: TButton; 
       NMSMTP1: TNMSMTP; 
       procedure FormCreate(Sender: TObject); 
       procedure Button1Click(Sender: TObject); 
       procedure Button2Click(Sender: TObject); 
       procedure Button3Click(Sender: TObject); 
       procedure NMSMTP1Failure(Sender: TObject); 
       procedure NMSMTP1SendStart(Sender: TObject); 
       procedure NMSMTP1Success(Sender: TObject); 
       private 
       { Private declarations } 
       public 
       { Public declarations } 
       end; 
      var 
       Form1: TForm1; 
      implementation 
      uses Unit2; 
      {$R *.DFM} 
      procedure TForm1.FormCreate(Sender: TObject); 
      begin 
       PageControl1.Pages[0].Caption:=‘Send Mail’; 
       self.Caption:=‘My Mailer’; 
       self.BorderIcons:=[biSystemMenu,biMinimize]; 
       self.BorderStyle:=bsSingle; 
       Application.Icon:=self.Icon; 
       Application.Title:=self.Caption; 
       with StringGrid1 do 
       begin 
       Cells[0,0]:=‘Host’; 
       Cells[1,0]:=‘To Address’; 
       Cells[2,0]:=‘From Address’; 
       Cells[3,0]:=‘Your Name’; 
       Cells[4,0]:=‘Subject’; 
       Cells[5,0]:=‘File’; 
       end; 
       Button2.Enabled:=False; 
       Button3.Enabled:=False; 
      end; 
      procedure TForm1.Button1Click(Sender: TObject); 
      begin 
       Form2.Show; 
      end; 
      procedure TForm1.Button2Click(Sender: TObject); 
      var 
      i:Integer; 
      begin 
       for i:=1 to StringGrid1.RowCount-2 do 
       with Nmsmtp1 do 
       begin 
       Host:=StringGrid1.Cells[0,i]; 
      PostMessage.ToAddress.Add(StringGrid1.Cells[1,i]); 
      PostMessage.FromAddress:=StringGrid1.Cells[2,i]; 
      PostMessage.FromName:=StringGrid1.Cells[3,i]; 
      PostMessage.Subject:=StringGrid1.Cells[4,i]; 
       PostMessage.Attachments.Add(StringGrid1.Cells[5,i]); 
       Connect; 
       Sendmail; 
       DisConnect; 
       end; 
       Button2.Enabled:=False; 
       Button3.Click; 
       end; 
      procedure TForm1.Button3Click(Sender: TObject); 
      var 
      i:Integer; 
      begin 
       with StringGrid1 do 
       begin 
       for i:=1 to RowCount-2 do 
       begin 
       Cells[0,i]:=‘’; 
       Cells[1,i]:=‘’; 
       Cells[2,i]:=‘’; 
       Cells[3,i]:=‘’; 
       Cells[4,i]:=‘’; 
       Cells[5,i]:=‘’; 
       end; 
       RowCount:=2; 
       end; 
       Button2.Enabled:=False; 
       Button3.Enabled:=False; 
      end; 
      procedure TForm1.NMSMTP1Failure(Sender: TObject); 
      begin 
       StatusBar1.SimpleText:=‘Mail send failure!’; 
      end; 
      procedure TForm1.NMSMTP1SendStart(Sender: TObject); 
      begin 
       StatusBar1.SimpleText:=‘Now Sending...’; 
      end; 
      procedure TForm1.NMSMTP1Success(Sender: TObject); 
      begin 
       StatusBar1.SimpleText:=‘Send Success!’; 
      end; 
      end. 
      Button1是“New Mail”按钮,Button 2是“Send”按钮,Button3是“Clear” 按钮。 
      以下是Unit2代码清单: 
      unit Unit2; 
      interface 
      uses 
       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 
    Dialogs, StdCtrls; 
      type 
       TForm2 = class(TForm) 
       OpenDialog1: TOpenDialog; 
       GroupBox1: TGroupBox; 
       GroupBox2: TGroupBox; 
       Edit1: TEdit; 
       Edit2: TEdit; 
       Edit3: TEdit; 
       Edit4: TEdit; 
       Edit5: TEdit; 
       Button1: TButton; 
       Button2: TButton; 
       Button3: TButton; 
       Label1: TLabel; 
       Label2: TLabel; 
       Label3: TLabel; 
       Label4: TLabel; 
       Label5: TLabel; 
       Label6: TLabel; 
       procedure Button1Click(Sender: TObject); 
       procedure Button2Click(Sender: TObject); 
       procedure Button3Click(Sender: TObject); 
       procedure FormActivate(Sender: TObject); 
       procedure FormCreate(Sender: TObject); 
       private 
       { Private declarations } 
       public 
       { Public declarations } 
       end; 
      var 
       Form2: TForm2; 
      implementation 
      uses Unit1; 
      {$R *.DFM} 
      procedure TForm2.FormCreate(Sender: TObject); 
      begin 
       self.Caption:=‘New Mail’; 
       self.BorderStyle:=bsDialog; 
      end; 
      procedure TForm2.FormActivate(Sender: TObject); 
      begin 
       Edit1.Text:=‘’; 
       Edit2.Text:=‘’; 
       Edit3.Text:=‘’; 
       Edit4.Text:=‘’; 
       Edit5.Text:=‘’; 
       Label1.Caption:=‘No File’; 
      end; 
      procedure TForm2.Button1Click(Sender: TObject); 
      begin 
       if OpenDialog1.Execute then 
       Label1.Caption:=Opendialog1.Filename; 
      end; 
      procedure TForm2.Button2Click(Sender: TObject); 
      var 
      i:Integer; 
      begin 
       if (Edit1.Text<>‘’) and (Edit2.Text<>‘’) and (Edit5.Text<>‘’) 
    and (Label1.Caption<>‘No File’) then 
       begin 
       with Form1.StringGrid1 do 
       begin 
       RowCount:=RowCount+1; 
       i:=RowCount-2; 
       Cells[0,i]:=Edit1.Text; 
       Cells[1,i]:=Edit2.Text; 
       Cells[2,i]:=Edit5.Text; 
       Cells[3,i]:=Edit3.Text; 
       Cells[4,i]:=Edit4.Text; 
       Cells[5,i]:=Label1.Caption; 
       end; 
       Form1.Button2.Enabled:=True; 
       Form1.Button3.Enabled:=True; 
       end; 
       self.Hide; 
      end; 
      procedure TForm2.Button3Click(Sender: TObject); 
      begin 
       self.Hide; 
      end; 
      end. 
      Edit1、Edit2、Edit3、Edit4、Edit5编辑框分别用于填写服务器名称、收件 
    人地址、发件人名称、邮件主题和发件人地址。 
      现在一个E-mail发送程序就完成了。你可以试一试,自已给自已发几封邮件, 
    用FoxMail之类的软件是否能收到信。顺便说一句,本文就是用这个自编程序发到 
    编辑部的。 ■ 作者:钱可栋 
     
        
      

  10.   

    我做过
    请联系:
    [email protected]
      

  11.   


    我大力推荐你用WinShoes组件包,非常好用,我现在决定今后再也不用FastNet了。
    我在做一个通过e-mail打包数据同步的程序时,开始用FastNet总有些什么问题.....,用了
    WinShoes就不同了。
      

  12.   

    williamgui:
        winshoes组件包在哪里?怎么用?
      

  13.   


    下面这个地址有:
    URL http://go.163.com/~delphi6/download/winshoes7037.exe有个Demo目录,一看例子,就应该知道怎么用了。
      

  14.   

    用DELPHI的FastNet有可能性做到和FOXMEAIL一样吗?
      

  15.   

    用FastNet中的Tnsmtp,很容易的。
      

  16.   

    看一下DELPHI的帮助,我看帮助曾做过一个收发功能的小程序,
    帮助介绍的十分详细。(FastNET中的NSMTP与POP的帮助)。
      

  17.   

    可以用 sakemail控件很好用
      

  18.   

    其实邮件程序编写不仅仅是发送和接收过程,我认为难度是解码/编码。
    假如需要最大的灵活度,还是自己用TClientSocket等基本控件编写的好。
    我编的《商务导航》软件就没有用到任何其他的高级控件,因此修改、控制很灵活,适应性很强。