Sending Mail from ASP.NET web page using

This article will demonstrate you how to send email from a ASP.NET web page.
  • 1554

This article will demonstrate you how to send email from a web page. Sending email is very common in application. In order to send an email from an web page, you have to use the SmtpMail class, found in the System.Net.Mail namespace, which contains a static method Send.

We use the
SmtpMail and MailMessages classes of the namespace for this purpose. The MailMessages class provides properties and methods for constructing an Email message.

Sending Mail from ASP.NET

@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<script runat="server">
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
     Dim message As New System.Net.Mail.MailMessage("")
     message.Subject = "Sending Mail with ASP.NET 2.0"
     message.Body = "sending email"
     Dim smtp As New System.Net.Mail.SmtpClient("localhost")
  End Sub
html xmlns="" >
<head id="Head1" runat="server">
  <title>ASP.NET Mail</title>
  <form id="form1" runat="server">

The above code sends an email and the email is queues to the disk.


More Articles

© 2020 DotNetHeaven. All rights reserved.