PDA

View Full Version : How do I submit my form to email


nlkday
01-13-2011, 08:53 PM
Hi- I have this code in ASP page and it's a basic form. I want this form to be able to submit to an email address once filled out. I can't seem to figure it out. This is also a password protected page, if that matters. I'm a newbie at ASP coding. Help please... Thanks!

<%@ LANGUAGE="VBSCRIPT" %>

<html>
<head>
<title>RockyMounts Dealer Access</title>
<style type="text/css">
<!--
body, td { font-family: arial; font-size: 12px; }
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
background-image: url(http://www.rockymounts.com/v/dealers/images/background_dealer.jpg);
background-repeat: repeat;
}
.style2 {
font-size: 14px;
color: #009ddc;
}
.style4 {
color: #009DDC;
font-weight: bold;
font-size: 14px;
}
.style6 {color: #FFFFFF}
.style7 {color: #CCCCCC}
#apDiv1 {
position:absolute;
left:514px;
top:269px;
width:415px;
height:393px;
z-index:1;
background-color: #000000;
}
.style8 {
color: #000000;
font-weight: bold;
}
a:link {
color: #FFFFFF;
text-decoration: underline;
}
a:visited {
text-decoration: underline;
color: #CCCCCC;
}
a:hover {
text-decoration: none;
color: 009ddc;
}
a:active {
text-decoration: underline;
}
.style9 {
color: #009ddc;
font-weight: bold;
font-size: 14px;
}
.style11 {color: #999999; }
.style13 {color: #CC0000}
.style14 {
color: #8F2B2B;
font-weight: bold;
}
.style16 {color: #009ddc}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<table width="940" border="0" align="center" cellpadding="5" bgcolor="#000000">
<tr>
<td valign="top" bgcolor="#333333"><h2><img src="/v/dealers/images/dealersiteheader.jpg" alt=""></h2>
<HR size="1" color="gray">
<p align="center"><span class="style2">How to deal when you set your eyes on a nice rack</span><strong><br>
</strong>Howdy Partna! Did you stumble upon these parts to grab info, pricing, and order forms? <br>
Oh good, cause that's the direction we was 'bound to take. Carry on now... We's got work to do.</p>
<HR size="1" color="black">
<p><span class="style6">PLEASE LOGIN.</span> <span class="style7">If you do not have login access or forget your login please email <a href="mailto:sales@rockymounts.com">sales@rockymounts.com</a>.</span></p>
<p>
<!--#include file="flogin.asp"-->
</p>
<div id="downloads">
<table width="500" border="0" align="right" cellpadding="5" cellspacing="0" bordercolor="009ddc" bgcolor="#000000">

<tr>
<td colspan="2" valign="top" bgcolor="#333333"><span class="style4"><img src="/v/dealers/images/smokey.jpg" alt="RockyMounts" align="left"></span></td>
</tr>
<tr>
<td width="82" valign="top" bgcolor="#999999"><span class="style8">DEALER PACK:</span></td>
<td width="398"><p>&gt; <a href="http://www.rockymounts.com/v/catalog/2011catalog.html" target="_blank">online catalog</a></p>
<p>&gt; <a href="/v/dealers/2011dealer_price_sheet.pdf" target="_blank">price sheet</a></p>
<p>&gt; order form</p>
<p>&gt; terms &amp; conditions</p> </td>
</tr>
<tr>
<td valign="top" bgcolor="#333333">&nbsp;</td>
<td bgcolor="#333333">&nbsp;</td>
</tr>
<tr>
<td height="40" valign="top" bgcolor="#999999"><span class="style8">NEWS &amp; UPDATES:</span></td>
<td>
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 5,
interval: 6000,
width: 400,
height: 600,
theme: {
shell: {
background: '#000000',
color: '#009edc'
},
tweets: {
background: '#000000',
color: '#ffffff',
links: '#888b8c'
}
},
features: {
scrollbar: false,
loop: false,
live: false,
hashtags: false,
timestamp: true,
avatars: false,
behavior: 'all'
}
}).render().setUser('RockyMountsStoc').start();
</script></td>
</tr>
<tr>
<td height="40" valign="top" bgcolor="#333333">&nbsp;</td>
<td bgcolor="#333333">&nbsp;</td>
</tr>
<tr>
<td height="40" valign="top" bgcolor="#999999"><span class="style8">COMING SOON:</span></td>
<td><p>&gt; DriveShaft (15mm/20mm thru axel adapter)</p>
<p>&gt; JawBridge (Upright rooftop mount)</p>
<p>&gt; HangUp (Hitch rack)<br>
</p></td>
</tr>
<tr>
<td height="40" valign="top" bgcolor="#333333">&nbsp;</td>
<td bgcolor="#333333"><div align="right"><strong><a href="http://www.rockymounts.com" target="_blank">RockyMounts.com --&gt;</a></strong></div></td>
</tr>
</table>
<p class="style4">&nbsp;</p>
<p class="style9">Quick Order:</p>
<p class="style2">FROM: </p>
<form name="dealer order" method="post" action="/emailform.asp">
<label>
<input name="from" type="text" id="from" value="Store name and location" size="50" maxlength="80">
</label>
</form>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Clutch SD | $32.50 <span class="style16">(Backordered)</span></p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Locking Clutch | $25.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
9mm Clutch | $12.50</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
9mm Clutch/Box of Ten | $112.50</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
TieRod Total</p>
<blockquote>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Black | $70.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Silver | $70.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Red | $70.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
White | $70.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Blue | $70.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Green | $70.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Orange | $70.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Yellow | $70.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Pink | $70.00</p>
</blockquote>
<p>
<input name="Quantity2" type="text" value="#" size="8" maxlength="3">
PitchFork Total</p>
<blockquote>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Black | $53.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Silver | $53.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Red | $53.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
White | $53.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Blue | $53.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Green | $53.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Orange | $53.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Yellow | $53.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Pink | $53.00</p>
</blockquote>
<p>
<input name="Quantity2" type="text" value="#" size="8" maxlength="3">
Euro PitchFork Total</p>
<blockquote>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Black | $58.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Silver | $58.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Red | $58.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
White | $58.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Blue | $58.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Green | $58.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Orange | $58.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Yellow | $58.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Pink | $58.00</p>
</blockquote>
<p>
<input name="Quantity2" type="text" value="#" size="8" maxlength="3">
TandemMount R4 | $47.50</p>

<p>
<input name="Quantity2" type="text" value="#" size="8" maxlength="3">
9mm Noose | $185.00</p>

<p>
<input name="Quantity2" type="text" value="#" size="8" maxlength="3">
9mm Lariat | $37.50</p>

<input name="Quantity2" type="text" value="#" size="8" maxlength="3">
Lock Cores
<blockquote>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
1-pack | $5.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
2-Pack | $10.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
4-Pack | $19.00</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
6-Pack | $27.50</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
8-Pack | $32.50</p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
24-Pack | $96.00</p>
</blockquote>

<label>
<input name="dropship" type="checkbox" id="dropship" value="This is a Dropship">
</label>
<span class="style13">This is a Dropship</span> <span class="style11">(If this box is checked that means we will dropship all items on this form to the below address).
</span>

<blockquote>

<label><span class="style13">Dropship to this address</span><span class="style14">:</span>
<textarea name="dropship address" cols="50" id="dropship address"></textarea>
</label>
</blockquote>
<br><br>
<label>
<input name="terms" type="checkbox" id="terms" value="required" checked>
I understand that by submitting this form I agree to all items processed, shipped, and billed to my account filed under RockyMounts.</label>
<br>
If you do not agree and this box is not checked we will not process this order. </p>

<p>&nbsp;</p>


<input type="button" name="submit" id="submit" value="submit">
<input type="hidden" name="email_From" value="sales@rockymounts.com">
<input type="hidden" name="email_To" value="sales@rockymounts.com">
<input type="hidden" name="email_Subject" value="Dealer Order">
<input type="hidden" name="email_ThankYou" value="Thank you for submitting your order.">
<input type="hidden" name="email_Redirect" value="dealeraccess.asp">
<br />
<br /><br />Please enter the following code into the box provided:<br /><script type="text/javascript">
function Play_CAPTCHA_Sound(surl) {
if (document.all) {
if (!document.getElementById('captcha_bgsound')) {
var bgsound = document.createElement('bgsound');
bgsound.id = 'captcha_bgsound';
document.body.appendChild(bgsound);
}
document.getElementById('captcha_bgsound').src = surl;
}
else {
if (!document.getElementById('captcha_embed')) {
var embed = document.createElement('span');
embed.id = 'captcha_embed';
document.body.appendChild(embed);
}
document.getElementById('captcha_embed').innerHTML = '<embed src="' + surl + '" hidden="true" autostart="true" />';
}
}

</script>



</form>
</div>
<p>
<% If Session("LoggedIn") = fsecstr Then
Select case Session("LoginName")
case "admin" %>
</p>
<!--#include file="secure/admin.asp"-->
<% case "faiz" %>
<!--#include file="secure/faiz.asp"-->
<% case "mike" %>
<!--#include file="secure/mike.asp"-->
<% case default %>
'do nothing if not a proper username
<% end select
End If %></td>
</tr>
<tr>
<td bgcolor="#000000"><div align="left" class="style11">RockyMounts Official Dealer Access<br>
</div>
<div align="right" class="style11"> &copy; copyright 2011</div></td>
</tr>
</table>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
</body>
</html>

Old Pedant
01-13-2011, 09:49 PM
Why did you show us the <form> page???? It has nothing, directly, to do with sending the email.

The page you needed to show was "emailform.asp"

Though looking at it again, your <form> is badly messed up. You have all those fields named "Quantity". How will you ever know which quantity goes with which product????

That's just nutso.

Instead of stuff like
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Clutch SD | $32.50 <span class="style16">(Backordered)</span></p>
<p>
<input name="Quantity" type="text" value="#" size="8" maxlength="3">
Locking Clutch | $25.00</p>
<p>
...

you need something like:

<input name="Clutch SD@32.50" type="text" value="#" size="8" maxlength="3">
Clutch SD | $32.50 <span class="style16">(Backordered)</span></p>
<p>
<input name="Locking Clutch@25.00" type="text" value="#" size="8" maxlength="3">
Locking Clutch | $25.00</p>
<p>

or something along those lines. Even better would be to use SKU's in place of product name. Or or or ...

I think you need to rethink this entire project.

Maybe it's time to hire somebody?

nlkday
01-13-2011, 10:26 PM
Wow! Ok. It's a bit of a rough draft and like I said, I'm a newbie. I get what you mean by naming the stuff differently- makes sense.

This is my emailform.asp page code. This is all stuff I gathered from the internet. No big deal if it's not worth your time. But, I would like to learn and I thought this would be how. Thanks for the feedback! I renamed all my input tags.

<%
'Sends an email
Dim mail
Set mail = Server.CreateObject("CDO.Message")
mail.To = Request.Form("nlkday@yahoo.com.com")
mail.From = Request.Form("From")
mail.Subject = Request.Form("Subject")
mail.TextBody = Request.Form("Body")
mail.Send()
Response.Write("Mail Sent!")
'Destroy the mail object!
Set mail = nothing
%>

Old Pedant
01-14-2011, 12:03 AM
Ummm...no.

You want to send all the NON-ZERO quantities in the email, don't you??

So probably you want to do something like this:

<%
'Sends an email
Dim mail
Set mail = Server.CreateObject("CDO.Message")
mail.To = "nlkday@yahoo.com.com" ' NO REQUEST.FORM HERE!
mail.From = Request.Form("From")
mail.Subject = Request.Form("Subject")

body = "The following items were ordered:" & vbNewLine
For Each name In Request.Form
val = Request.Form(Name)
If Left(Name,1) = "$" AND val <> "" AND val <> "#"
body = body & Mid(Name,2) & " : " & val & vbNewLine
End If
Next

mail.TextBody = body
mail.Send()
Response.Write("Mail Sent!")
'Destroy the mail object!
Set mail = nothing
%>

You will need to make one further change to your form fields.

All the fields that are for order items needs some kind of way to determine that they *are* order items. One easy way would be give each one a one-character prefix. Here, I have assumed it to be the "$" character, but it could be anything of your choice...even an underline or dash or whatever.

That is, you would need to use
<input name="$Clutch SD@32.50" type="text" value="#" size="8" maxlength="3">

So only if the form field starts with your designated magic character and only if the value of the field is something other than blank or "#" (because that's what you have as the default in each one) do you add that name and its value to the list of ordered items in the email.

You also might need to set up a CDO.Configuration. Without one, your CDO.Message will use all the default settings for CDO, and those may or may not be appropriate to the server you are using.

If this is a shared server (that is, on some hosting company), you should ask them what CDO.Configuration you need.

Other alternatives: You could format the email as HTML (instead of as plain text).

Finally, you are doing

mail.From = Request.Form("From")
mail.Subject = Request.Form("Subject")

But your <form> doesn't contain any fields by those names.

Specifically it has hidden fields such as these:

<input type="hidden" name="email_From" value="sales@rockymounts.com">
<input type="hidden" name="email_To" value="sales@rockymounts.com">
<input type="hidden" name="email_Subject" value="Dealer Order">
<input type="hidden" name="email_ThankYou" value="Thank you for submitting your order.">
<input type="hidden" name="email_Redirect" value="dealeraccess.asp">

Make up your mind which names you are going to use; be consistent.

nlkday
01-15-2011, 12:30 AM
You're good! Thank you for the help! I'm going to tackle this next week. I'll let you know how it pans out...