Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Automatically sending E mail

Title: Automatically sending E-mail Question: How can I automatically send an E-mail Answer: This can quite easily be done by using the following code. In this example an E-mail is automatically sent after the button is pressed. NOTE: You need the 'TNMSMTP' component for this method. This component comes as a standard with Delphi 4 and 5 and is found on the 'Fastnet' tab. procedure TForm1.Button1Click(Sender: TObject); begin NMSMTP1.Host := 'smtp.mailserver.com'; NMSMTP1.UserID := 'h.abdullah'; NMSMTP1.Connect; NMSMTP1.PostMessage.FromAddress := 'hasan@excite.com'; NMSMTP1.PostMessage.ToAddress.Text := 'someone@xmail.com'; NMSMTP1.PostMessage.Body.Text := 'Type the body of the message here'; NMSMTP1.PostMessage.Subject := 'subject goes here'; NMSMTP1.SendMail; end;