The System.Web.Mail namespace in ASP.NET 1.0 is replaced by System.Net.Mail namespace in ASP.NET 2.0 for sending an email.The System.Net.Mail namespace contains the SmtpClient and MailMessage Classes to send the email.
Lets see how to create and send an email in ASP.NET 2.0.
'First imports namespace
Imports System.Net.Mail
'create an instance of MailMessage class
Dim message As MailMessage = New MailMessage()
'Set From address
message.From = New MailAddress("from@servername.com", "From Name")
'ReplyTo address
message.ReplyTo = New MailAddress("reply@servername.com", "ReplyTo Name")
'To address
message.To.Add(New MailAddress("to1@servername.com", "Name One"))
message.To.Add(New MailAddress("to2@servername.com", "Name Two"))
'Send Email with CC address
message.CC.Add(New MailAddress("cc@servername.com", "CC Name"))
'Send Email with BCC address
message.Bcc.Add(New MailAddress("bcc@servername.com", "BCC Name"))
message.Subject = "Subject"
message.Body = "This is a plain text"
'set body type(Text/HTML) of message
message.IsBodyHtml = False
'Set Priority property : Low, Normal and High
message.Priority = MailPriority.Normal
'Create an instance of the SmtpClient class for sending the email
Dim emailClient As New SmtpClient("mail.server.com")
'Send an Email
emailClient.Send(message)