How to send an e-mail in ASP.NET?

Question

How to send an e-mail in ASP.NET?

Re: How to send an e-mail in ASP.NET?

The first thing that you need is the SMTP service. SMTP service should be up and running. And you also need to import the namespace, System.Web.Mail. To create a mail object, you need to create an instance of MailMessage. MailMessage has all required properties such as To, Subject, BCC, CC etc.
How to send an email from an ASP .NET page?
<%@ Import Namespace="System.Web.Mail" %>

Sub Page_Load(Sender As Object, E As EventArgs)

Dim msg as New MailMessage()

msg.To = "das@silicomm.com"
msg.From = "das@aspalliance.com"
msg.Subject = "test"
'msg.BodyFormat = MailFormat.Html
msg.BodyFormat = MailFormat.Text
msg.Body = "hi"

SmtpMail.SmtpServer = "localhost"

SmtpMail.Send(msg)
msg = Nothing
lblMsg.Text = "An Email has been send to " & "das@silicomm.com"

End Sub