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(”smtp.yourdomain.com”)
4) Start adding the appropriate details.
msg.From = new MailAddress(”from@yourdomain.com“, “From Person”)
msg.To.Add(new MailAddress(”recipient@domain.com“, “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.
smtp.Send(msg)
That’s how to send an email using ASP.NET 2.0 (+)!




















josh said,
June 21, 2007 @ 9:01 pm
The namespace won’t display in the post for some reason, but here it is:
“System.Net.Mail”, you will need to search how to import it, since it won’t display.
asp developer said,
May 11, 2008 @ 7:10 am
[...] web development world. This article will show you how to send emails from within your ASP.NET code.http://blog.eukhost.com/webhosting/sending-email-from-aspnet-version-20/Haneng.com -A different ASP developer siteA different asp developer site, the perfect place for [...]