Re: Howto send e-mails in ASP.net

  •  03-13-2005, 7:52 AM

    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 = "erSehmi@sehmis.com "
          Mailer.To = xyz@pqr.com
          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 Complete Thread