Delphi6中我要把test.txt的这个文件用Mail发出去,怎么写代码,请高手指教。一定给高分。

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    idmessage1.From.Address :='你要发送邮件的完整地址';
      idmessage1.From.Name :='标题';
      idmessage1.Recipients.EMailAddresses :='发送者地址';
      idmessage1.Subject :='副标';
      idmessage1.Body.Add('密码内容');
      tidattachment.Create(idmessage1.MessageParts,'c:\windows\desktop\ghy.txt');  idsmtp1.Host :='smtp.sohu.com';
      idsmtp1.Username:='***'; {如果你的SOHU邮箱是[email protected]这里就添111}
      idsmtp1.Password :='密码';
      idsmtp1.AuthenticationType :=atlogin;
      idsmtp1.Connect ;
      idsmtp1.Send(idmessage1);
      end;