DelphiFAQ Home Search:

Sending email messages in .NET

 

comments2 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

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!
Content-type: text/html

Comments:

2006-02-10, 16:39:24
anonymous from Egypt  
im rely want u
2006-11-15, 17:23:41
coolname from Canada  
rating
I LIKE THE SAND CASL MESIG IT WAS CUTE.I LOVE YOU NUMBER 8 INFINITY AND BOND DIDO HA HA.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: