Dear All,
How to send email from ASP.NET? .. please advise .. thanks a lot in advance
Regards
Winanjaya
Printable View
Dear All,
How to send email from ASP.NET? .. please advise .. thanks a lot in advance
Regards
Winanjaya
Real basic sample here.
VB Code:
Sub btnSend_Click(s as Object, e as EventArgs) Dim newMail as New MailMessage newMail.From = txtFrom.Text newMail.To = txtTo.Text newMail.Subject = txtSubject>text newMail.BodyFormat = MailFormat.Html newMail.Body = txtMessageContent.Text SmtpMail.SmtpServer = "ServerNameHere" SmtpMail.Send(newMail) End Sub
Don't forget to put your
at the top of the page. That is assuming you are doing your code inline. If not, just do your import on the code behind page as you would for a windows form.VB Code:
<%@ import Namespace="System.Web.Mail" %>