Hello,
Can you help me out in making this work? What I want is as simple as sending
form values to an email.
The code I am using is the following:
<Script runat="server">
Private Sub Page_Load()
Dim msg As EmailMessage = New EmailMessage("localhost")
Dim msgTo, msgFrom, msgName, msgSubject, msgMessage
msgTo = Request.Form("to")
msgFrom = Request.Form("from")
msgName = Request.Form("name")
msgSubject = Request.Form("subject")
msgMessage = Request.Form("message")
' Set the email type
msg.BodyFormat = MailFormat.Html
' Set the from address
msg.FromAddress = msgFrom
' Set the to address
msg.To = msgTo
' Set the from name
msg.FromName = msgFrom
' Set the email subject
msg.Subject = msgSubject
' Set the email message
msg.Body = "<html><head><style type='text/css'>body {font-family:
Verdana, Arial, Helvetica, sans-serif; font-size: 11px;color: #333333;
background-color: </style></head><body>" &_
"<strong>New Message</strong>" &_
"<br><strong>From: </strong>" & msgFrom &_
"<br><strong>Name: </strong>" & msgName &_
"<br><strong>To: </strong>" & msgTo &_
"<br><strong>Subject: </strong>" & msgSubject &_
"<br><strong>Message Text</strong>" &_
"<br> " & msgMessageField &_
"</body></html>"
' Internal Exceptions
msg.ThrowException = False
' Logging and LogBody
msg.Logging=false
msg.LogBody = false
' Sends Message
If msg.Send() Then
' Redirects to error page
Response.Redirect("status.aspx?result=contactErr")
Else
' Redirects to confirmed page
Response.Redirect("status.aspx?result=contactOk")
End If
End Sub
</script>
I really would appreciate if you could send me a working example using my
code. I am trying to make it work for 1 week and until now I had no luck.
The form has 5 text inputs: to, from, name, subject and message AND a button
which when pressed should send the form values in the email.
I tryied to comment everything I could think of. I am working in ASP.net /
VB.
Thank You Very Much,
Miguel Moura 1 2118
Miguel
You don't say exactly what doesn't work with yours (empty form fields, no mail message, etc.), but anyway I would do it in the code-behind (not in the html). Here's a simplified example
Private Sub btnSubmit_Click(ByVal sender As Object,
ByVal e As System.EventArgs) Handles btnSubmit.Clic
' Send the message..
Dim msg As New Mail.MailMessag
msg.To = txtTo.Tex
msg.From = txtFrom.Tex
msg.Body = txtMessage.Tex
Mail.SmtpMail.SmtpServer = "My Mail Server
Mail.SmtpMail.Send(msg
End Su
The form itself just has txtTo, txtFrom, and txtMessage as the IDs of input fields and btnSubmit as the ID of the submit button
If you're not getting any messages sent at all, you might check your smtp server. I don't know all the ins and outs, but do know that you can only use localhost if your box is configured to send mail (mine isn't, and I think it also has to do with the o/s)
hth
Bil
----- Miguel Dias Moura wrote: ----
Hello
Can you help me out in making this work? What I want is as simple as sendin
form values to an email
The code I am using is the following
<Script runat="server"
Private Sub Page_Load(
Dim msg As EmailMessage = New EmailMessage("localhost"
Dim msgTo, msgFrom, msgName, msgSubject, msgMessag
msgTo = Request.Form("to"
msgFrom = Request.Form("from"
msgName = Request.Form("name"
msgSubject = Request.Form("subject"
msgMessage = Request.Form("message"
' Set the email typ
msg.BodyFormat = MailFormat.Htm
' Set the from addres
msg.FromAddress = msgFro
' Set the to addres
msg.To = msgT
' Set the from nam
msg.FromName = msgFro
' Set the email subjec
msg.Subject = msgSubjec
' Set the email messag
msg.Body = "<html><head><style type='text/css'>body {font-family
Verdana, Arial, Helvetica, sans-serif; font-size: 11px;color: #333333
background-color: </style></head><body>" &
"<strong>New Message</strong>" &
"<br><strong>From: </strong>" & msgFrom &
"<br><strong>Name: </strong>" & msgName &
"<br><strong>To: </strong>" & msgTo &
"<br><strong>Subject: </strong>" & msgSubject &
"<br><strong>Message Text</strong>" &
"<br> " & msgMessageField &
"</body></html>
' Internal Exception
msg.ThrowException = Fals
' Logging and LogBod
msg.Logging=fals
msg.LogBody = fals
' Sends Messag
If msg.Send() The
' Redirects to error pag
Response.Redirect("status.aspx?result=contactErr"
Els
' Redirects to confirmed pag
Response.Redirect("status.aspx?result=contactOk"
End I
End Su
</script
I really would appreciate if you could send me a working example using m
code. I am trying to make it work for 1 week and until now I had no luck
The form has 5 text inputs: to, from, name, subject and message AND a butto
which when pressed should send the form values in the email
I tryied to comment everything I could think of. I am working in ASP.net
VB
Thank You Very Much
Miguel Moura This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kassam |
last post by:
Hi MVPs out there.
I have constructed an order form and the users will enter the informtion. I
now need to send the filled out form as an e-mail (body being the HTML with
the fille din data) to...
|
by: varun |
last post by:
hello friends,
i have been developing an application in asp.net.
i want to inherit a web page on all other web pages of
my application.
i took a form and callded it mybaseform1.
then i...
|
by: Miguel Dias Moura |
last post by:
Hello,
Can you help me out in making this work? What I want is as simple as sending
form values to an email.
The code I am using is the following:
|
by: Miguel Dias Moura |
last post by:
Hello,
i have an ASP.net / VB page with a Script (submitValues) and a Form.
1. The form has 20 input texts and a "Submit" button.
2. The script declares 20 variables. The value of each...
|
by: Sandy |
last post by:
Hello -
I want to be able to send an email from my app that contains the logo from
my website at the top of it. I have searched the web and there are many
components out there, but isn't there...
|
by: Miguel Dias Moura |
last post by:
Hello,
Can you help me out in making this work? What I want is as simple as sending
form values to an email.
The code I am using is the following:
|
by: Miguel Dias Moura |
last post by:
Hello,
i have an ASP.net / VB page with a Script (submitValues) and a Form.
1. The form has 10 input text and a "Submit" button.
2. The script declares 10 variables. The value of each variable...
|
by: YMPN |
last post by:
Hi Everyone,
I'm deen from Riyadh.
Please do help me with some problem i have. I have this formview
control setup to recieved inputs from user (textbox, dropdownlist,
others).
After...
|
by: chaitanya02 |
last post by:
Hi All,
Well- this question might have appeared several times on this forum- but would appreciate your reply on this:
I have a asp page, where customers login with some username and the pwd,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |