Hi,
I am trying to send an e-mail from a web form. I am using Visual Basic in Visual Studio 2008. I am also using ASP.NET and a SQL Server 2005 database. I have found some code for this but it seems to be always for a Windows form and I keep coming across errors saying the code is "obsolete". Here is sample code I have been trying to use:
Imports System.Web.Mail
Partial Class QueryPage
Inherits System.Web.UI.Page
Dim objMail As New MailMessage()
Private Sub btnSend_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSend.Click
objMail.From = Me.txtFrom.Text.ToString
objMail.To = Me.txtTo.Text.ToString
objMail.Subject = Me.txtSubject.Text.ToString
objMail.Body = Me.txtMessage.Text.ToString
objMail.BodyFormat = MailFormat.Html
SmtpMail.Send(objMail)
Me.lblMessage.Text = "Email has been sent"
End Sub
End Class
I was confused when I started finding this so hard to do because I thought it would be a simple job. Any help would be greatly appreciated!
Thanks,
Orla
I am trying to send an e-mail from a web form. I am using Visual Basic in Visual Studio 2008. I am also using ASP.NET and a SQL Server 2005 database. I have found some code for this but it seems to be always for a Windows form and I keep coming across errors saying the code is "obsolete". Here is sample code I have been trying to use:
Imports System.Web.Mail
Partial Class QueryPage
Inherits System.Web.UI.Page
Dim objMail As New MailMessage()
Private Sub btnSend_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSend.Click
objMail.From = Me.txtFrom.Text.ToString
objMail.To = Me.txtTo.Text.ToString
objMail.Subject = Me.txtSubject.Text.ToString
objMail.Body = Me.txtMessage.Text.ToString
objMail.BodyFormat = MailFormat.Html
SmtpMail.Send(objMail)
Me.lblMessage.Text = "Email has been sent"
End Sub
End Class
I was confused when I started finding this so hard to do because I thought it would be a simple job. Any help would be greatly appreciated!
Thanks,
Orla