funkyspirit
Programmer
Hello,
I have an ASP page that contains a form. Once the user submits the form, the information is sent to an email address using a CDO email object and a popup message appears saying that the information has been sent.
What I would like to do is to create an onclick event on the submit button that will trigger the creation of the email and the sending of the information. Since the email generation code is in the same page as the form that would prevent the email from being sent if the form is empty.
The submit button is an image and so far I haven't been able to get it to work.
I have an ASP page that contains a form. Once the user submits the form, the information is sent to an email address using a CDO email object and a popup message appears saying that the information has been sent.
What I would like to do is to create an onclick event on the submit button that will trigger the creation of the email and the sending of the information. Since the email generation code is in the same page as the form that would prevent the email from being sent if the form is empty.
The submit button is an image and so far I haven't been able to get it to work.
Code:
<input type="image" name="submit" src="images/submit.png" width="115" height="39"/>
if request.Form("submit")<>"" then
Set myMail=Server.CreateObject("CDO.Message")
myMail.Subject="Contact Request"
myMail.From = Request.Form("email")
myMail.To= "xxx@xxx.com"
'myMail.CC="xxx@xxx.com"
myMail.TextBody = "Name:"& Request.Form("name")& vbcrlf & vbcrlf & _
"Email:" & Request.Form("email") & vbcrlf & vbcrlf & _
"Telephone:" & Request.Form("telephone") & vbcrlf & vbcrlf & _
"Length of separation:" & Request.Form("separation") & vbcrlf & vbcrlf & _
"Location:" & Request.Form("location") & vbcrlf & vbcrlf & _
"Other location:" & Request.Form("other_location") & vbcrlf & vbcrlf
"Divorce Agreed:" & Request.Form("divorce_agreement") & vbcrlf & vbcrlf & _
"Comments:" & Request.Form("comments")
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")=2[/URL]
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] _
="127.0.0.1"
'Server port
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] _
=25
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
%>
<script language="javascript"type="text/javascript">
alert("Thank you! Your request has been sent. One of our team members will be in touch with you shortly")
</script>
<%end if%>