.NET Framework namespace System.Net.Mail contains many classes developers can use to send all types of emails in ASP.NET 2.0. In the following tutorial I will show you how you can send a simple plain text emails in ASP.NET 2.0.
C#
using System.Net.Mail;
string mailFrom = "[email protected]";
string mailTo = "[email protected]";
string subject = "ASP.NET Test Email";
string messageBody = "This email is send to you from ASP.NET";
// Create Mail Message Object
MailMessage message = new MailMessage(mailFrom, mailTo, subject, messageBody);
// Create SmtpClient class object to Send MailMessage
SmtpClient client = new SmtpClient();
// Here you specify your smtp host address such as smtp.myserver.com
client.Host = "localhost";
client.Send(message);
VB.NET
Dim mailFrom As String = "[email protected]"
Dim mailTo As String = "[email protected]"
Dim subject As String = "ASP.NET Test Email"
Dim messageBody As String = "This email is send to you from ASP.NET"
' Create Mail Message Object
Dim message As New MailMessage(mailFrom, mailTo, subject, messageBody)
' Create SmtpClient class object to Send MailMessage
Dim client As New SmtpClient()
' Here you specify your smtp host address such as smtp.myserver.com
client.Host = "localhost"
client.Send(message)
This website is observed to be an excellent website for e-learning. Some complicated programming modules have been explained very appropriately.
I pay tribute to Mr. Waqas for creating such a knowledgeable website. God bless you.