|
|
Article : 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.
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 (+)!
| |
| |
|