Sending Email from ASP.NET (Version 2.0+)

Sending Email from ASP.NET (Version 2.0+)

ASP.NET is Microsoft’s revolutionary web application technology. ASP.NET has many features built in which other web language framworks don’t support, for example AJAX and drag-n-drop technologies.

In this article you will learn how to send emails from an ASP.NET (.aspx) page.

Note: This will only work with version 2.0+ of the framwork.

1) Import the mail namespace into the page.

2) Create the sub-routine that will send the email.

Sub SendEmail(ByVal Sender As Object, ByVal e As EventArgs)

End Sub

To send the mail on page load use the follow sub-routine.

Sub PageLoad(ByVal Sender As Object, ByVal e As EventArgs)

End Sub

Note: All sub-routines must be surrounded by the following tags.

Sub-routine here.

3) Declare the appropriate variables.

Dim msg As MailMessage = new MailMessage()

Dim smtp As New SmtpClient(“”)

4) Start adding the appropriate details.

msg.From = new MailAddress(“[email protected]”, “From Person”)

msg.To.Add(new MailAddress(“[email protected]”, “Recipient”))

msg.IsBodyHtml = “False”  ‘Set this to “True” if the message body will be HTML.

msg.Body = “Email Body”

msg.Subject = “The Subject”

5) Send the email.


That’s how to send an email using ASP.NET 2.0 (+)!

If you need a more powerful web hosting solution to cope with increasing demand, visit our homepage.