DelphiFAQ Home Search:
General :: Programming :: Delphi :: .NET
Starting in .NET or already familiar but having a question? You might find it answered here!

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Sending email messages in .NET

Delphi 8 for .NET makes it easier to send emails even with attachments. The System.Web.Mail namespace provides the necessary classes for sending email in .NET; follow this example.

uses System.Web.Mail;
 
 procedure SendAnEmail;
 
 var
   MailMessage: System.Web.MailMessage;
 
 begin
   MailMessage := MailMessage.Create;
   try
     with MailMessage do
     begin
       From := 'me@hotmail.com';
       &To := 'you@yahoo.com';
       Subject := 'Important news';
       Body := 'email body text here';
 
       BodyFormat := System.Web.Mail.MailFormat.Text;
     end; { with MailMessage }
 
     SmtpMail.SMTPSERVER := 'SMTPSERVER name';
     SmtpMail.Send(MailMessage)
   except
     on e : Exception do
       MsgResult.Text := 'Error occured!';
   end; { try }
 end;
You don't like the formatting? Check out SourceCoder then!
Generated 0:01:26 on Nov 21, 2017