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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send html email on button click

Status
Not open for further replies.

nogscript

Programmer
Sep 30, 2004
3
AU
Hi
I am attempting to send an html email based on user selections. Page one offers a list of selections which can be selected, then submitted to page two which shows the consolidated result from page one. In the process of consolidating the result, I am also building the html string which needs to be emailed once the user chooses the final submit... (basically what is being emailed is exactly what is shown on the 2nd page less the buttons).

All this works fine except that I cannot get the email to be submitted on a button push, rather it is being emailed as soon as the page is loaded. I am sure I am missing something obvious, but any help would be appreciated...following is a shortened version of the code:

<html>
<head>

<script language="vbscript">
sub TestSend()
<%
Dim oSendMailer

Set oSendMailer = Server.CreateObject("CDONTS.NewMail")
oSendMailer.To = "aaa@aa.com"
oSendMailer.From = "bb@bb.com"
oSendMailer.Subject = htmlMess

oSendMailer.BodyFormat = 0
oSendMailer.MailFormat = 0

oSendMailer.Body="Test Message 1"
oSendMailer.Send
set oSendMailer = nothing
%>
end sub
</script>

</head>

<body>

<!-- code here which displays the results and builds the html string for the email-->

<form>
<input type="button" value="Click" onclick="call TestSend()">
</form>

</body>
</html>
 
Hello noqscript,

Structured as such, it will send when the page is loaded. Server side script will be executed first no matter what, that means email is sent, leaving an empty sub Testsend if you source view on the client.

One way to do it is that you put the testsend on the action requested page. With the input button onclick, you submit the form.
[tt] <form name=...etc action="testsendpage.asp" method=...etc>[/tt]

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top