Imports System.Web.Mail
Private Sub SendMail_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles SendMail.Click
Dim mailMessage As New MailMessage()
mailMessage.From = TextBox1.Text
mailMessage.To = "admin@dotnet.itags.org.startvbdotnet.com"
'you also can set this to TextBox2.Text
mailMessage.Cc = TextBox3.Text
mailMessage.Bcc = TextBox4.Text
mailMessage.Subject = TextBox5.Text
mailMessage.BodyFormat = MailFormat.Text
mailMessage.Body = TextBox6.Text
'textbox6 TextMode property is set to MultiLine
mailMessage.Priority = MailPriority.Normal
SmtpMail.SmtpServer = "mail.yourserver.com"
'mail server used to send this email. modify this line based on your mail server
SmtpMail.Send(mailMessage)
Label6.Text = "Your mail was sent"
'message stating the mail is sent
End Sub
Private Sub Reset_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Reset.Click
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
TextBox5.Text = " "
TextBox6.Text = " "
'resetting all the value to default i.e null
End Sub
I need where on the aspx page it needs to go.
I am a complete newbie to ASP.NET
You can either put the code in a seperate code file or in the same file as the web form towards the top in between script tags.
< script runat="server" >
[Code here]
< / script >
Whew!, well I finaly got it to work!. Now I want a button on the samepage, when clicked will send the broser to a new URL. Is this possible?
Thanks,
Paul
If you add Response.Redirect("SomeUrl") to the bottom of the SendMail_Click method, it will redirect to a URL after it executes all the code. If you just want a redirect button, then a simple input button will do.
< input type="button" value="Button Text" onClick="window.location.href='SomeUrl'" / >
0 comments:
Post a Comment