首页  编辑  

利用TNMSMTP发送邮件

Tags: /超级猛料/Network.网络通讯/电子邮件/   Date Created:

procedure TForm1.Button1Click(Sender: TObject);

begin

 NMSMTP1.Host   := 'mail.host.com';

 NMSMTP1.UserID := 'Username';

 NMSMTP1.Connect;

 NMSMTP1.PostMessage.FromAddress       := 'webmaster@swissdelphicenter.ch';

 NMSMTP1.PostMessage.ToAddress.Text    := 'user@host.com';

 NMSMTP1.PostMessage.ToCarbonCopy.Text := 'AnotherUser@host.com';

 NMSMTP1.PostMessage.ToBlindCarbonCopy.Text := 'AnotherUser@host.com';

 NMSMTP1.PostMessage.Body.Text         := 'This is the message';

 NMSMTP1.PostMessage.Attachments.Text  := 'c:\File.txt';

 NMSMTP1.PostMessage.Subject           := 'Mail subject';

 NMSMTP1.SendMail;

 ShowMessage('Mail sent !');

 NMSMTP1.Disconnect;

end;