Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending form information using CDO email object

Status
Not open for further replies.

funkyspirit

Programmer
Oct 6, 2011
12
GB
Hello,

I have an asp page that contains a form. Once completed the form sends the information to an email address using a vbscript CDO email object.

What I would like to do is that the form is only sent if completed and when the user clicks the submit button, which is an image.

Once the email has been sent, I would like a popup message to appear.

Every way I have tried to do it did not work.

Any idea how to do this?

Thank you.
 


hi,
Every way I have tried to do it did not work.
Please list "Every way" you tried and the actual observed result, be it an error message on statement, data or no observable result.

"did not work" is ambiguous and contributes nothing to our understanding.

More information required.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi,

Sorry for being vague.

What I tried is to set-up an onclick event for the submit button which would call a vbscript function to create and send the email. I used MsgBox and alert to create the pop-up message but I got a permission denied error when using MsgBox and a type mismatch error when using alert.

Then I tried to embed JavaScript in the vbscript function, but I got a type mismatch error as well.

Unfortunately, I do not have this code anymore as I changed it to something that works but with which I can only use a standard submit button, not an image as I'd like to.

Thanks.
 
If you have it working with a submit button, and your only problem is that you want an image to be clicked to submit the form (instead of a submit button), just change the onclick event of the image to submit the form, like "javascript:document.formname.submit();
 
Or if I misread your explanation, you will probably need to show the code that is not working
 
Hi Guitarzan,

The code that is not working is below:

<input type="submit" name="submit" value="Submit" src="images/submit.png" width="115" height="39"/>

this is the button as a classic submit button. I would like to have an Onclick event on this button, that would trigger the code below:
<%
Set myMail=Server.CreateObject("CDO.Message")
myMail.Subject="xxxxxxxx"
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 _

(" 'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
(" _
="127.0.0.1"
'Server port
myMail.Configuration.Fields.Item _
(" _
=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>
I would like to have an onclick event so that the form is not sent if it is not filled in ( in case of a page refresh for example). I would also like to include the alert code so that the message pops up when and only when the email has been sent.

Thank you.
 
Your questions relate more to ASP and server side / client side issues than to vbScript, so I would re-post in forum333.

Something like this should give you a hyperlink that submits the form (just as an example):
Code:
<a href='#' onclick='javascript:document.[highlight]formname[/highlight].submit();'>
<img src='myimage.gif' /></a>

You can only use alert / msgbox on the client (and even then, msgbox would only work in IE). They won't work in server-side ASP code. There are ways around it, but why not display the message on the ASP page you are submitting the form to, rather than use a popup?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top