Howto send e-mails in ASP.net

Last post 03-13-2005, 7:52 AM by Arsh. 1 replies.
Sort Posts: Previous Next
  •  03-11-2005, 2:42 AM 4532

    Howto send e-mails in ASP.net

     
     
     Hi,
     
         How to send mail using asp.net
         I m using SMTPMAIL class
          Is there is another better way



     Amar 
  •  03-13-2005, 7:52 AM 4563 in reply to 4532

    Re: Howto send e-mails in ASP.net

    From: Er. Arshvinder Singh Sehmi


     
    You can use the System.Web.Mail.MailMessage and the System.Web.Mail.SmtpMail class to send e-mail in your ASPX pages. Below is a simple example of using this class to send mail
     
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Web" %>
    <%@ Import Namespace="System.Web.Mail" %>
    <HTML>
      <HEAD>
       <title>Mail Test</title>
      </HEAD>
       <script language="VB" runat="server">
        Sub Page_Load(sender As Object, E as EventArgs)
         Try
          Dim Mailer As MailMessage
          Mailer = New MailMessage()
          Mailer.From = "[email protected] "
          Mailer.To = [email protected]
          Mailer.Subject = "Your Order"
          Mailer.Body = "Your order was processed."
          Mailer.BodyFormat = MailFormat.Text
           SmtpMail.SmtpServer = " MAil Server Name or IP"  
         SmtpMail.Send(Mailer)
         Response.Write("Mail sent successfully")
       Catch ex As Exception
         Response.Write("Your message was not sent: " + ex.Message)
       End Try
     End Sub
     </script>
     <body>
      <form id="mail_test" method="post" runat="server">
      </form>
     </body>
    </HTML>
     

    Regards,
    Er. Arshvinder Singh Sehmi
    .NET Professional and Programmer
    India

View as RSS news feed in XML