要做个能收发电子邮件(用SMTP和POP协议)的模块?各位大侠能否给个源代码示例?

解决方案 »

  1.   

    用Indy呗……这个,看看相关文档吧……
      

  2.   

    想和你共同开发可以吗?一起学习
    我的email:[email protected]
      

  3.   

    //receive
      try
        NMPOP31.Connect;
      except
        lpText:= '连接POP3服务器失败。请检查通信设置是否正确,稍后再试。'+CHR(13)+
                 '[状态:连接]'+CHR(13)+CHR(13)+
                 'WinSock Error: [10060] Connection timed out.';
        MessageBox(Application.Handle, PChar(lpText), PChar(frmDataReceive.Caption), MB_OK+MB_ICONERROR);
      end;     screen.Cursor := crHourGlass ;  mailcelln := 0 ;
      if NMPOP31.MailCount > 0 then
       begin
       //mailcelln控制符合条件的邮件显示到stringgrid1中.
           for getM := 1 to NMPOP31.MailCount do
             retrieveEnd(false);
           stringgrid1.RowCount := mailcelln + 1 ;
       //      NMPOP31.GetSummary(getM);   //mailcelln 变量改为控制将stringgrid1中显示的邮件实现接收到本地.
           for mailcelln := 1 to stringgrid1.RowCount-1 do
           begin
              retrieveEnd(true) ;          mailcount := mailcount + NMPOP31.MailMessage.Attachments.Count ;         for m := 0 to NMPOP31.MailMessage.Attachments.Count-1 do
             begin    //对附件进行处理              zbfilestr := NMPOP31.MailMessage.Attachments.Strings[m] ;
                  ....
             end;       end;
           mailcelln := mailcelln-1 ;   end
       else
           ShowMessage('没有可接收的邮件!');  NMPOP31.Disconnect;
      screen.Cursor := crDefault ;  showmessage('接收了 '+inttostr(mailcelln)+'个新邮件! 恢复了'+inttostr(mailcount)+'个数据文件!') ;
    //发送部分自己考虑吧,差不多的
      

  4.   

    用Indy呗……这个,看看indy本身代的例程不就可以啦!!!
      

  5.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
      IdTCPClient, IdMessageClient, IdSMTP, StdCtrls;type
      TForm1 = class(TForm)
        Label1: TLabel;
        edt_SMTP: TEdit;
        Label2: TLabel;
        edt_From: TEdit;
        Label3: TLabel;
        edt_To: TEdit;
        Lable4: TLabel;
        edt_Username: TEdit;
        Label4: TLabel;
        edt_Psw: TEdit;
        Label5: TLabel;
        edt_Subject: TEdit;
        Label6: TLabel;
        Memo1: TMemo;
        Label7: TLabel;
        edt_File: TEdit;
        Button1: TButton;
        Button2: TButton;
        OpenDialog1: TOpenDialog;
        IdSMTP1: TIdSMTP;
        IdMessage1: TIdMessage;
        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
    //添加附件
    Opendialog1.Filename:='';
    Opendialog1.Filter:='所有文件|*.*';
    if Opendialog1.Execute then
      begin
      edt_File.Text:=Opendialog1.FileName;
      end;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    //
    IdMessage1.From.Address:=edt_From.Text;
    //
    IdMessage1.From.Name:=edt_Username.Text;
    //
    Idmessage1.Recipients.EMailAddresses:=edt_To.Text;
    //
    Idmessage1.Subject:=edt_Subject.Text;
    //
    Idmessage1.Body.Add(Memo1.Text);
    //
    TidAttachment.Create(Idmessage1.MessageParts,edt_File.Text);
    //
    Idsmtp1.Host:=edt_SMTP.Text;
    //
    Idsmtp1.Username:=edt_Username.Text;
    //
    Idsmtp1.Password:=edt_Psw.Text;
    //
    Idsmtp1.AuthenticationType:=atLogin;
    //
    Idsmtp1.Connect();
    //
    Idsmtp1.Send(Idmessage1);
    end;end.
      

  6.   

    各位大侠能否发一份到我的MAIL重:[email protected],
    在线求救!!!!先谢了!