Forum Moderators: phranque

Message Too Old, No Replies

ASP Mail Issue

Well I had the form working, then I tried adding this attachment....

         

jollygoodfella

7:16 am on Feb 13, 2005 (gmt 0)

10+ Year Member



Well I had the form working, then I tried adding this attachment and now the freaking thing doesn't work at all. The data only gets emailed to me but without any of the user inputted data. If anyone has insight on how to get the HTTP Post back working too that would be great as well. I know that i Have to add the 'enctype="multipart/form-data"' in the <form> tag as well as my "<input type="file" name="file">" field, but I was having trouble with the http postback. That's when I had trouble with all this other crap.

I have been looking at this code for 6 hours and haven't had any luck.

Here is the code for the page with the aspmail code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'First lets Dim all the variables we need
Dim Mailer
Dim MyBody
Dim Myemail
Dim Myfirstname
Dim Mylastname
Dim Myplaque_6x8_quantity
Dim Myplaque_8x10_quantity2
Dim Myplaque_10_5x13_quantity3
Dim Myplaque_stand_quantity
Dim Mytext_wanted_on_plaque
Dim Myplaque_design
Dim Mybilling_phone
Dim Myshipping
Dim Mypayment_type
Dim Myaccount_number
Dim Myexpiration
Dim Mythree_digit_code
Dim Mycomments

'Now lets get some values for the variables from the form
Myemail = Request.Form("email")
Myfirstname = Request.Form("firstname")
Mylastname = Request.Form("lastname")
Myplaque_6x8_quantity = Request.Form("plaque_6x8_quantity")
Myplaque_8x10_quantity2 = Request.Form("plaque_8x10_quantity2")
Myplaque_10_5x13_quantity3 = Request.Form("plaque_10_5x13_quantity3")
Myplaque_stand_quantity = Request.Form("plaque_stand_quantity")
Mytext_wanted_on_plaque = Request.Form("text_wanted_on_plaque")
Myplaque_design = Request.Form("plaque_design")
Mybilling_phone = Request.Form("billing_phone")
Myshipping = Request.Form("shipping")
Mypayment_type = Request.Form("payment_type")
Myaccount_number = Request.Form("account_number")
Myexpiration = Request.Form("expiration")
Mythree_digit_code = Request.Form("three_digit_code")
Mycomments = Request.Form("comments")

'Now lets build the body of the email from the data in the form
MyBody = MyBody & "First Name: "& Myfirstname & vbcrlf
MyBody = MyBody & "Last Name: "& Mylastname & vbcrlf
MyBody = MyBody & "Email: "& Myemail & vbcrlf
MyBody = MyBody & "plaque_6x8_quantity: "& Myplaque_6x8_quantity & vbcrlf & vbcrlf
MyBody = MyBody & "plaque_8x10_quantity2: "& Myplaque_8x10_quantity2 & vbcrlf
MyBody = MyBody & "plaque_10_5x13_quantity3: "& Myplaque_10_5x13_quantity3 & vbcrlf
MyBody = MyBody & "plaque_stand_quantity: "& Myplaque_stand_quantity & vbcrlf & vbcrlf
MyBody = MyBody & "text_wanted_on_plaque: "& Mytext_wanted_on_plaque & vbcrlf & vbcrlf
MyBody = MyBody & "plaque_design: "& Myplaque_design & vbcrlf & vbcrlf
MyBody = MyBody & "billing_phone: "& Mybilling_phone & vbcrlf & vbcrlf
MyBody = MyBody & "shipping: "& Myshipping & vbcrlf & vbcrlf
MyBody = MyBody & "account_number: "& Myaccount_number & vbcrlf & vbcrlf
MyBody = MyBody & "payment_type: "& Mypayment_type & vbcrlf & vbcrlf
MyBody = MyBody & "expiration: "& Myexpiration & vbcrlf & vbcrlf
MyBody = MyBody & "three_digit_code: "& Mythree_digit_code & vbcrlf & vbcrlf
MyBody = MyBody & "comments" & Mycomments

'Now lets put the variables and other information we need into the mailing script
mailTo= Request.Form("mailTo") & "sample@sample.com"
Subject= Request.Form("Subject")
Message= Request.Form("Message")

Set Mailer = Server.CreateObject ("SMTPsvg.Mailer")
Mailer.FromName = "OrderIt!"
Mailer.FromAddress = "sample@example.com"
Mailer.Subject = "Your Order from FotoPlaques.com " & Subject
Mailer.BodyText = MyBody
'Modifying RemoteHost due to internal network changes. Should just be mail-fwd now.
'Mailer.RemoteHost = ""
Mailer.RemoteHost = "mail-fwd"

Mailer.AddRecipient mailTo, mailTo

if Mailer.SendMail then
' Message sent sucessfully
response.write "Thank you for your order. We will process your order within 38 hours"
else
' Message send failure
response.write "Your message was not sent.<br>"
response.write "The error was: " & Mailer.Response & "<br>"
end if
Set Mailer = Nothing
%>

Any help would be most wonderful, and heck I might even buy you a drink;)

Mark

[edited by: txbakers at 2:02 am (utc) on Feb. 14, 2005]
[edit reason] no specific email address per TOS [/edit]

Corey Bryant

5:29 pm on Feb 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not too sure, but try to dim email,firstname,lastname etc and see if that helps.

-Corey

Ultraseeker

12:47 am on Feb 14, 2005 (gmt 0)

10+ Year Member



Does the line:
mailTo= Request.Form("mailTo") & "sample@example.com" need a space before the form input value and the email shown?

I would try to test the line:
Mailer.AddRecipient mailTo, mailTo with some test values to make sure everything else is working.

If it isn't, try working from the last known good code and add/test each new line of code.

[edited by: txbakers at 2:03 am (utc) on Feb. 14, 2005]
[edit reason] no specific email addresses per TOS [/edit]

jollygoodfella

9:50 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



Well I think you are on the right track Ultra. The first 3 sections of code should be fine and I think the problem lies in the 4th section where the configuration mailings are.

The thing that makes me most mad about this is that I had the form working properly 2 days ago, then I tried adding the attachments field then this crap happened.

Once we get this working I'll be sure to make a backup.

Ultraseeker

10:52 pm on Feb 14, 2005 (gmt 0)

10+ Year Member



Glad I could help. This kind of thing can drive you mad. Usuallly it's something that you "ass-ume" is correct... It's always best to backup and test incrementally. If you have cvs installed that's always the best way to go, although I get lazy about it sometimes.

Isn't debugging fun?

jollygoodfella

4:12 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



i'm not sure what else to do here. i have tried testing things and i'm still getting this info sent:


First Name:
Last Name:
Email:
plaque_6x8_quantity:
plaque_8x10_quantity2:
plaque_10_5x13_quantity3:
plaque_stand_quantity:
text_wanted_on_plaque:
plaque_design:
billing_phone:
shipping:
account_number:
payment_type:
expiration:
three_digit_code:
comments

but still none of the variables are being sent. can anyone tell me if this would mean that someplace the variables that I "dim" out are incorrect? i haven't changed anything on the actual form itself that sends the data over, any more insight would be oh so lovely.

mark

Ultraseeker

6:32 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



If you're just getting blanks, it's probably your form element names.
In the line
Myfirstname = Request.Form("firstname")
You're looking passing the form element "firstname" to the var Myfirstname. Make sure your form elements match.
Maybe if you posted the whole thing along with the HTML from the form it might help get a full picture of what's going on.

jollygoodfella

6:58 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



Ok, here's the form page code

<form action="cgi-bin/orderit.asp" method="post" enctype="multipart/form-data">
<p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Order Your Plaque</strong><br>
<br>
<strong>Step 1 <br>
SELECT PLAQUE SIZE &amp; QUANTITY COST </strong></font></p>
<table width="527" border="0">

<tr>
<td width="34" bgcolor="#CCCCCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Qty.</font></div></td>
<td width="348" bgcolor="#EEEEEE"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Size</font></div></td>
<td width="131" bgcolor="#FFFFCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Price </font></div></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><div align="center">

<font size="2" face="Arial, Helvetica, sans-serif">
<input name="plaque_6x8_quantity" type="text" id="plaque_6x8_quantity5" value="0" onfocus="if (this.value == '0') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = '0'; } return true;" size="5">
</font></div></td>
<td bgcolor="#EEEEEE"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">6&quot; X 8&quot;</font></div></td>
<td bgcolor="#FFFFCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">$24.99 </font></div></td>
</tr>
<tr>

<td bgcolor="#CCCCCC"><div align="center">
<font size="2" face="Arial, Helvetica, sans-serif">
<input name="plaque_8x10_quantity2" type="text" id="plaque_8x10_quantity2" value="0" onfocus="if (this.value == '0') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = '0'; } return true;" size="5">
</font></div></td>
<td bgcolor="#EEEEEE"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">8&quot; X 10&quot;</font></div></td>
<td bgcolor="#FFFFCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">$29.99 <br>
</font></div></td>

</tr>
<tr>
<td bgcolor="#CCCCCC"><div align="center">
<font size="2" face="Arial, Helvetica, sans-serif">
<input name="plaque_10_5x13_quantity3" type="text" id="plaque_10_5x13_quantity3" value="0" onfocus="if (this.value == '0') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = '0'; } return true;" size="5">
</font></div></td>
<td bgcolor="#EEEEEE"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">10.5&quot; X 13&quot;</font></div></td>

<td bgcolor="#FFFFCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"> $36.99 </font></div></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">
<input name="plaque_stand_quantity" type="text" id="plaque_stand_quantity" value="0" onfocus="if (this.value == '0') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = '0'; } return true;" size="5">
</font></div></td>
<td bgcolor="#EEEEEE"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"> Plaque Stand (For Tabletop Presentation)</font></div></td>

<td bgcolor="#FFFFCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">$3.00 </font></div></td>
</tr>
</table>
<p>&nbsp;</p>
<p><font size="2" face="Arial, Helvetica, sans-serif"><strong> Step 2 <br>
ENTER TEXT WANTED ON YOUR PLAQUE </strong><br>
(Hint: Include names, organization, dates, location, or anything that helps personalize plaque) <br>

<br>
l
<textarea name="text_wanted_on_plaque" cols="60" rows="5" id="text_wanted_on_plaque"></textarea>
<br>
Maximum 360 characters <br>
(Note: sample will not be accountable for typing errors made by the customer. </font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif">Example text provided below:</font></p>
<table width="909" border="0">

<tr bgcolor="#FFFFCC">
<td width="309"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><u><strong>Triathlon / Marathon Individual Sport</strong></u></font></div></td>
<td colspan="2"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><u><strong>School Sports</strong></u></font></div></td>
<td colspan="2"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><u><strong>Academics</strong></u></font></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td rowspan="2"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Paul Truman</strong> <font color="#CCCCCC">aa </font>1 Hr 34 Min 12 Sec<br>

New Horizon Triathlon Series<br>
June 23, 2005</font></div></td>
<td colspan="2" bgcolor="#EEEEEE"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>2005 State Volleyball Champions</strong></font></div>
<div align="center"></div></td>
<td colspan="2" valign="top"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Middleton Middle School </strong><br>
2005 Top 10 Student Honors</font></div></td>

</tr>
<tr>
<td width="124" valign="top" bgcolor="#EEEEEE"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Tracy Adams <br>
Linda Elmers<br>
Sheri Dufore <br>
Elaine Koore <br>
Lindsay Poor <br>

Tanya Smith <br>
Janet Wren <br>
</font></div></td>
<td width="133" valign="top" bgcolor="#EEEEEE"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Hellen Bork <br>
Marie Fitzgerald<br>
Tammy Gustoff<br>

Debbie Moore<br>
Sarah Quincy<br>
Heather Tollway<br>
Alexis Zorn</font></div></td>
<td valign="top" bgcolor="#CCCCCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Thomas Rhorer 4.00 GPA <br>
David Finkus 4.00 GPA <br>

Julie Dohrn 4.00 GPA <br>
Mike Holmes 3.97 GPA <br>
Tina Smith 3.96 GPA </font></div></td>
<td valign="top" bgcolor="#CCCCCC"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Lisa Gruder 4.00 GPA<br>
William Tudor 4.00 GPA<br>
Lynn Weise 4.00 GPA<br>

Elise Wyatt 3.96 GPA<br>
Orvis Dylan 3.95 GPA</font></div></td>
</tr>
<tr bgcolor="#FFFFCC">
<td>&nbsp;</td>
<td colspan="2" valign="top"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">COACHES: <br>
Debbie Barr and Tracy Shore</font></div></td>

<td width="153" valign="top"><div align="center"> </div></td>
<td width="168" valign="top">&nbsp;</td>
</tr>
</table>
<p><font size="2" face="Arial, Helvetica, sans-serif"><br>
<strong><br>
Step 3 <br>
SELECT PLAQUE DESIGN </strong><br>

</font></p>
<table width="574" border="0">
<tr bgcolor="#EEEEEE">
<td width="262"><div align="left"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong> Integrated Image and Text </strong></font></div></td>
<td width="292"><div align="center"> </div></td>
</tr>
<tr bgcolor="#FFFFCC">

<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>
<input type="radio" name="plaque_design" value="integrated_Landscape">
Landscape </strong></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>
<input type="radio" name="plaque_design" value="integrated_portrait">
Portrait</strong></font></div></td>
</tr>
<tr bgcolor="#FFFFCC">

<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong><img src="../Images/intlandscape.jpg" width="90" height="63"> </strong></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong><img src="../Images/intportrait.jpg" width="49" height="64"> </strong></font></div></td>
</tr>
<tr bgcolor="#EEEEEE">
<td><div align="left"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong>Separated Image and Text </strong></font></div></td>
<td><div align="center"></div></td>
</tr>

<tr bgcolor="#FFFFCC">
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>
<input type="radio" name="plaque_design" value="separated_Landscape">
Landscape</strong></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>
<input type="radio" name="plaque_design" value="separated_Portrait">
Portrait </strong></font></div></td>
</tr>

<tr bgcolor="#FFFFCC">
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><img src="../Images/seplandscape.jpg" width="70" height="49"></font></div></td>
<td><div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><img src="../Images/sepportrait.jpg" width="49" height="64"></font></div></td>
</tr>
</table>
<p><font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="plaque_design" value="no_artwork_photo_only">
No Artwork or Text - Photo Mounted Only <br>

<input type="radio" name="plaque_design" value="allow_foto_plaques_to_choose">
Allow Foto Plaques to select best option <br>
<br>
Step 4<br>
ATTACHMENTS (Maximum 5 Total Images) </strong></font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif"> If you would like special graphics added please email those to <a href="mailto:sample@sample.com">email</a> with &quot;Please add images to my plaque&quot; as the subject title.</font></p>

<p><font size="2" face="Arial, Helvetica, sans-serif"> <strong>Step 5 <br>
PLEASE ADD BILLING NAME</strong> - If using a credit card, please ensure the name is as stated on the card. </font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif"> First Name:
<input name="firstname" type="text" id="firstname" value="Your First Name" onfocus="if (this.value == 'Your First Name') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = 'Your First Name'; } return true;">
</font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif">Last Name:
<input name="lastname" type="text" id="lastname" value="Your Last Name" onfocus="if (this.value == 'Your Last Name') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = 'Your Last Name'; } return true;">

</font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif"> E-Mail:
<input name="email" type="text" id="email" value="Your Email" onfocus="if (this.value == 'Your Email') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = 'Your Email'; } return true;">
</font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif"> Phone (include area code):
<input name="billing_phone" type="text" id="billing_phone" value="Your Phone Number" onfocus="if (this.value == 'Your Phone Number') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = 'Your Phone Number'; } return true;">
<br>
<br>
(Note: We respect customer privacy. We do not sell or share our customer lists) </font></p>

<p><font size="2" face="Arial, Helvetica, sans-serif"> <strong>Step 6 <br>
SELECT SHIPPING AND HANDLING OPTIONS</strong> </font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif">
<input type="radio" name="shipping" value="ground">
Ground $6.25 <br>
<input type="radio" name="shipping" value="second_day">

Second Day $14.50 Note: Shipping cost is per item but will be discounted for multiple items. <br>
<input type="radio" name="shipping" value="overnight">
Overnight $19.50 <br>
<br>
Contact <a href="mailto:sample@sample.com">sample</a> for international orders </font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif"> <strong>Step 7 <br>

ENTER PAYMENT INFORMATION</strong></font></p>
<font size="2" face="Arial, Helvetica, sans-serif"></font>
</font><font size="2" face="Arial, Helvetica, sans-serif"><select name="payment_type" id="payment_type">
<option selected>Please choose a Payment Method</option>
<option value="mastercard">Master Card</option>
<option value="visa">Visa</option>
<option value="invoice_me">Invoice Me</option>

</select>
</font>
<p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Credit Card Information:</strong></font> </p>
<p><font size="2" face="Arial, Helvetica, sans-serif">Credit Card Number </font> <font size="2" face="Arial, Helvetica, sans-serif">
<input name="account_number" type="text" id="account_number" value="Credit Card Number" onfocus="if (this.value == 'Credit Card Number') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = 'Credit Card Number'; } return true;">
<br>
Expiration Date (mo/yr) </font> <font size="2" face="Arial, Helvetica, sans-serif">

<input name="expiration" type="text" id="expiration" value="Exp Date" onfocus="if (this.value == 'Exp Date') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = 'Exp Date'; } return true;">
<br>
</font> <font size="2" face="Arial, Helvetica, sans-serif">Three Digit Code on Signature Side</font> <font size="2" face="Arial, Helvetica, sans-serif">
<input name="three_digit_code" type="text" id="three_digit_code" value="3-digit code" onfocus="if (this.value == '3-digit code') { this.value = ''; } return true;" onblur="if (this.value == '') { this.value = '3-digit code'; } return true;">
<br>
</font> <font size="2" face="Arial, Helvetica, sans-serif"><br>
(Note: All information is kept confidential and private)</font> </p>

<p><font size="2" face="Arial, Helvetica, sans-serif">If you wish to pay by Money Order please email us at: <a href="mailto:sample@sample.com">sample@sample.com</a></font> </p>
<p><font size="2" face="Arial, Helvetica, sans-serif"> <strong>Step 8 <br>
ENTER COMMENTS </strong></font></p>
<font size="2" face="Arial, Helvetica, sans-serif">
<textarea name="comments" cols="60" rows="5" id="comments"></textarea>
</font>
<p><font size="2" face="Arial, Helvetica, sans-serif"><br>

<strong>Step 9 <br>
CONFIRM INFORMATION </strong><br>
<br>
Press button to check order Verify <br>
<br>
<strong>Step 10 <br>
SUBMIT ORDER </strong><br>

<br>
<input type="submit" name="Submit" value="Submit Order &gt; &gt;">
<br>
<br>
(Note: Order copy will be confirmed to the e-mail provided) </font></p>
<p><font size="1" face="Arial, Helvetica, sans-serif"> <b>DISCLAIMER: Foto Plaques will not be accountable for information incorrectly <br>
entered by the customer. Unless noted in the &quot;ENTER COMMENTS&quot; section <br>

above, Foto Plaques, LLC reserves the right to use plaques in future <br>
marketing brochures. We will do our best to deliver the best looking plaques <br>
possible which might include the need to modify the plaque layout to maximize <br>
customer benefit. Liability on the part of Foto Plaques will be limited to the <br>
cost of the plaque. Wisconsin residents add 5% sales tax to your total bill. </b></font></p>
<p><font size="2" face="Arial, Helvetica, sans-serif"> Please click below to e-mail us directly with any questions or feedback. <br>

Hopefully this helps:) I really do appreciate all of your help:)

Ultraseeker

8:14 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



Get rid of enctype="multipart/form-data" in the form tag.
You don't need it.

jollygoodfella

9:46 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



Oh my gosh I can't believe I forgot about that! Frickin' A!

Thank you sooooooo much! If you lived in my town I'd buy you a brewskie.

I am going to need that info in the <form> tag to get the attachment thing working though right? Have you ever used attachments in forms before? No worry if you haven't, that will be the next phase of the form that I'll work on, then finally having a Confirmation page.

:)

Thanks again for getting me to this point, its nice having another set of eyes on code:)

Mark

Ultraseeker

11:51 pm on Feb 15, 2005 (gmt 0)

10+ Year Member



No problem. It's always the little things that get you.
The inctype param will work fine once you have an actual input type=file element in your form...

Thanks
--J

[edited by: txbakers at 9:55 am (utc) on Feb. 19, 2005]
[edit reason] no self-promotions per TOS - thanks. [/edit]

jollygoodfella

9:44 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



Thank you all for you help. The form is now working awesome!

But I was wondering if any of you have even created a confirmation like page that customers could view the information they submitted and edit it, if htey need to, or just click submit to send it?

I have done some looking around but the only thing I have found is with the confirmation emails which is already a part of what I'm doing.

Also is there a simple solution for adding up to 5 attachments that will also get emailed?

Thanks again, you guys are great...

Mark

Ultraseeker

10:34 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



Instead of sending the message right away you can just display what they typed as html (with response.write) and stick every parameter and value in hidden form vars. They can submit that page to confirm or hit back to edit.
As far as uploading several attachments it's just a matter of adding as many input=file elements in the form. That should take care of it.
--j

jollygoodfella

4:38 am on Feb 22, 2005 (gmt 0)

10+ Year Member



ok Ultra, I'll try that. Thanks again for your help:) I'll add your link to my new website. You should Message me your link and I'll stick it on there. If you have an logo I'll throw that on my "partners" section too:)

Mark

jollygoodfella

6:19 am on Feb 22, 2005 (gmt 0)

10+ Year Member



Ok I got the information to send to a confirmation page, but how do I get the info on the confirmation page to submit? I'll keep looking into it, but if anyone has some information on this that would be great:)

I know that the data needs to get passed through somehow, I am just not sure how to get the data from the confirm page through.

Mark

jollygoodfella

6:30 am on Feb 22, 2005 (gmt 0)

10+ Year Member



To be more specific I have the Confirm page listing all of the variables and I have an Edit button and a Submit button. The edit button brings the user back a page to edit their information. The submit button sends the user through the mailing form and the data names get sent to my email, but none of the user inputted data. I'm sure its something simple that I am doing wrong, or maybe I'm missing a command.

Thanks again and if you want to see the code Let me know:) (as I have already posted much of it)

Mark

Ultraseeker

8:55 am on Feb 22, 2005 (gmt 0)

10+ Year Member



Your confirmation page should have this kind of html/asp code:

<%
Myfirstname = Request.Form("Myfirstname")
...
%>
<input type="hidden" name="Myfirstname" value="<%= Myfirstname %>">
...
fist name: = <%= Myfirstname %>
...

Your mailer page where you submit this to should have:
Myfirstname = Request.Form("Myfirstname")
MyBody = MyBody & "First Name: "& Myfirstname & vbcrlf
...

If you don't get the values you expect, just debug using response.write("MyBody") to see what comes in.

You should make sure that all the variables are named correctly on all three pages... Since you said only the names of the variables are shown in the message emailed to you, I'm sure it's just the <%= %> in the hiddend fields that are missing.
--j

jollygoodfella

5:32 am on Feb 24, 2005 (gmt 0)

10+ Year Member



Sweet:) The confirm page now works beautifully...now to the upload thing:)

I'll take your advice and see what I can do.

Mark

jollygoodfella

5:51 am on Feb 24, 2005 (gmt 0)

10+ Year Member



Ok I now added

enctype="multipart/form-data"

to the form field on the actual order.asp page and the confirmation page.

I also have

<input name="file1" type="file" id="file1">

on the order page

Finally I have on the confirmation page:

<input type="hidden" name="file1" value="<%= Myfile1 %>"><%= Myfile1 %>

Is this correct?

I don't get any VBScript errors, but now the email that I receive only shows the variable names and not any of the user inputted data or attachment file.

The confirmation page also does not show any of the user inputted data.

I used the same exact working form but just added the above information so I know that the variables and mailer is set correctly.

Hope this helps:)

Mark

Ultraseeker

10:01 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



"
<input name="file1" type="file" id="file1">

on the order page

Finally I have on the confirmation page:

<input type="hidden" name="file1" value="<%= Myfile1 %>"><%= Myfile1 %>

Is this correct?
"
As far as I know, the input type file cannot have a prefilled value. You could ask them to specify the file to upload on the confirmation page...
Since you know the form works, you could bypass the confirmation page and just do the form post along with the file upload in one step. The main reason you want a confirmation page is to make sure the user filled in the required fields. One way to do that is through Javascript. Pop up an error on submit if they don't fill in what you need. You could also use Javascript to confirm the upload.
--j

jollygoodfella

10:26 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



Yeah I know that I can use Javascript, but my client wants to have a confirmation page so that the user can verify his/her information is correct.

If the input type file cannot have a prefilled value then is there another way around that?

I could probable get away with the customer not seeing the attachment on the confirmation page, but I would obviously need the file to be emailed.

Ultraseeker

1:37 am on Feb 25, 2005 (gmt 0)

10+ Year Member



Here's a work-around.
On the first input page:

<form action="testuploadconfirm.asp" method="post" name="submitform">
fist name: <input type="text" name="myFirstName" value="" size="35" maxlength="255">
<br>
<input type="submit" name="Submit" value="Submit">
</form>

The confirmation page:

Confirm Information:
<br>
First name: <%= Session("myFirstName") %>
<br>
<form action="testuploadfile.asp" name="submitform" method="post" enctype="multipart/form-data">
Include attachment? <input type="file" name="myFile" size="35">
<br>
<input type="submit" name="Submit" value="Submit">
</form>

testuploadfile.asp, the target file for the mail application could then use the session values to set the mail message properties like the user's name and email. Then use the values from the input file for the attachment. Of course the file itself will have to be handled through the proper COM object like ASPSmartUpload:
[aspsmart.com...]

They've got great online docs and code samples.
Hope that helps.

jollygoodfella

12:11 am on Feb 27, 2005 (gmt 0)

10+ Year Member



Don't I have to add this info to the testuploadconfirm.asp page?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'First lets Dim all the variables we need
Dim MyBody
Dim myFirstName
Dim myFile

'Now lets get some values for the variables from the form
myFirstName = Request.Form("FirstName")
myFile = Request.Form("File")

Response.Write MyBody %>

Ultraseeker

3:24 am on Feb 27, 2005 (gmt 0)

10+ Year Member



You do have to take in all the variables on the confirm page and set your session vars in order to use them on your final post page where you handle the mail.

So on the confirm page:
<%
Session("myFirstName") = trim(Request.Form("myFirstName"))
'...
%>
...

<br>
First name: <%= Session("myFirstName") %>
<br>
<form action="testuploadfile.asp" name="submitform" method="post" enctype="multipart/form-data">
Include attachment? <input type="file" name="myFile" size="35">
<br>
<input type="submit" name="Submit" value="Submit">
</form>

A form with enctype="multipart/form-data" does not appear to handle regular input text values. That's why you don't get any values for them. In the example above I have the regular form set the session vars on the confirmation page that would then ask the user if he wants to upload a file. That page would then be able to handle the upload via the file input. Once the file is uploaded you can set your mailer script to handle the attachment. If no attachment is specified you can just send the email without attachment...

jollygoodfella

4:05 am on Mar 1, 2005 (gmt 0)

10+ Year Member



Ok so I have come a long way with this, but now I'm just trying to get over the hump.

Here is the code for each section that I am using:

Form page:

<form action="testuploadconfirm.asp" method="post" name="submitform">
first name:
<input name="Myfirstname" type="text" value="" size="35" maxlength="255">
<br>
<input type="submit" name="Submit" value="Submit">
</form>

Confirm Page and Upload form page:

<p><%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'First lets Dim all the variables we need
Dim MyBody
Dim Myfirstname
Dim Myfile

'Now lets get some values for the variables from the form
Myfirstname = Request.Form("Myfirstname")
Myfile = Request.Form("Myfile")

Response.Write MyBody %>

</p>
<p>Confirm Information:
<br>
First Name: <input type="hidden" name="Myfirstname" value="<%= Session("Myfirstname") = trim(Request.Form("Myfirstname")) %>">
<%= Myfirstname %>
<br>
</p>
<form action="testuploadfile.asp" name="submitform" method="post" enctype="multipart/form-data">
Include attachment? <input type="file" name="Myfile" size="35">
<br>
<input type="submit" name="Submit" value="Submit">
</form>

Mailer Page:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'First lets Dim all the variables we need
Dim MyBody
Dim Myfirstname
Dim Myfile

'Now lets get some values for the variables from the form
Myfirstname = Request.Form("Myfirstname")
Myfile = Request.Form("Myfile")

'Now lets build the body of the email from the data in the form
MyBody = MyBody & "First Name: "& Myfirstname & vbcrlf
MyBody = MyBody & "Attachment 1: " & Myfile

'Now lets put the variables and other information we need into the mailing script
mailTo= Request.Form("mailTo") & "sample@sample1234.com"
Subject= Request.Form("Subject")
Message= Request.Form("Message")

Set Mailer = Server.CreateObject ("SMTPsvg.Mailer")
Mailer.FromName = "OrderIt!"
Mailer.FromAddress = "sample@sample1234.com"
Mailer.Subject = "Your Order from FotoPlaques.com " & Subject
Mailer.BodyText = MyBody
'Modifying RemoteHost due to internal network changes. Should just be mail-fwd now.
'Mailer.RemoteHost = ""
Mailer.RemoteHost = "mail-fwd"

Mailer.AddRecipient mailTo, mailTo

if Mailer.SendMail then
' Message sent sucessfully
'response.write "Thank you for your order. We will process your order within 48 hours"
'else
' Message send failure
'response.write "Your message was not sent.<br>"
'response.write "The error was: " & Mailer.Response & "<br>"
'end if
'Set Mailer = Nothing
Response.Redirect "../thankyou.asp"
ELSE

' If there was an error in sending an email, this code will output to the screen
Set Mailer = Nothing
Response.Write "Your message was not sent."
Response.Write Mailer.Response
END IF
%>

I hate bothering you with this, but I just can't get things to work right.

With this situation earlier, with the code you gave me previously, my confirm page was only showing "True" and "False" statements for the user inputted data. So then I added this code:

<input type="hidden" name="Myfirstname" value="<%= Session("Myfirstname") = trim(Request.Form("Myfirstname")) %>">
<%= Myfirstname %>

Then the correct information showed up. But I am still having issues with the upload portion of the form.

We are soooo close with this I feel. If only I can get the upload thing done then I can finally lay this to rest.

Thanks again:)

-Mark

Ultraseeker

8:07 am on Mar 1, 2005 (gmt 0)

10+ Year Member



That's ok, I understand. I would just code it all for you, but it's the only way to learn... Making mistakes and learning from them is the best way to master it.

First the form page:
- make sure the form action=proper.confirm.target.page (that would be your confirm page filename)
- make sure all your variables are named correctly throughout

Confirm page:
- <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> is not needed - get rid of it
- at the top of the page before the html code, do the Session("Myfirstname") = trim(Request.Form("Myfirstname")) and repeat for all the variables you want to carry over to the final mailer page
- <input type="hidden" name="Myfirstname" value="<%= Session("Myfirstname") = trim(Request.Form("Myfirstname")) %>"> is wrong. It should be: <input type="hidden" name="Myfirstname" value="<%= Session("Myfirstname") %>">. The way you have it outputs the condition resulting from an assignment which is "true" in this case. So that's why you're seeing True as the value for your hidden params.
- as a matter of fact, you could just get rid of the hidden parameters since the values are stored in the session parameters. However you might consider keeping them there to make sure they get passed on to the final mailer page. Which may not happen if the user's session times out. Usually after 20 minutes by default. Who knows, maybe they went to the bathroom or ordered pizza before they clicked on submit.
- make sure the form action=proper.target.mailer.page (that would be your final mailer page filename)

Mailer page:
As I mentioned before you need to find out if your web service provider has an ASP upload COM object available for you to upload files from a web page. Something like the free ASPSmartUpload component:
[aspsmart.com...]
Please check this out and look at their sample code for uploading files.
What you need to understand is that in order to upload a file attachment (or any file to your server via HTTP POST) you need to have a file upload service available. This allows you to send the file to the server (ASP is server-side scripting) and then lets your scripts handle the file for further manipulation, like in the case of the mail attachment. But the file needs to be uploaded to the server first via this service. Otherwise you cannot mail it as an attachment because it is not accessible by the server.
From the FAQs at serverobjects.com:
I'm adding attachments but they aren't getting added to the actual mailing. What's wrong?
-The path specified is not valid.
-The user the component is running under, typically the anonymous IIS user, does not have rights to open the file. The anon IIS user, by default, cannot read from networked drives so a path such as \\foobar\files\myfile.zip is not valid.
-The file is open by another process that's denying reads to the file (another process you have running has the file open for writing and is denying read access).

Sorry to ramble on, but it's crucial that you understand that the file is not available to the server just by using a form, it has to be handled by a server-side service (file upload) and reside on the server prior to being available for mail attachment.

So I guess you need to find out what file upload service they have available first. Then you can make reference to it in your final page.

On the final mailer page:
- if you're still using hidden vars, use them to reset the session vars. It's good practice to do so anyway for reasons mentioned earlier.
- use the file upload service to store the file on the server or at least make reference to it so you can use it as an attachement.
- set your mail message properties using the session vars - if you use ASPSmartUpload it actually allows you to get values from regular form variables through the object's properties collection; there's some sample code you can get from their web site that shows you how to do it.

I'm sure you can get it all working with a little bit more perseverence.

Cheers,
--Jeffery

jollygoodfella

4:07 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



Jeffery you have been great:) Thank you for the information. I'm going to do what you said and call road runner and find out about the file upload. Maybe they don't even offer this service, I hope they do though.

Thanks again. About this:

if you're still using hidden vars, use them to reset the session vars. It's good practice to do so anyway for reasons mentioned earlier.

Is that what I am already doing? I'm picking up on a lot of this, but some of the terminology confuses me every once in a while.

Thanks again:)

Ultraseeker

9:16 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



No problem. By resetting the session variables on the final page I meant that you could do a similar thing there as you did for the confirmation page:

if (IsNull(Session("Myfirstname"))) then
'get the value from the hidden var through the file upload component's parameters collection -- see documentation.
end if

If the file upload component does not let you access a parameters collection and the session variables are null, you could just redirect the user to the first page with a message that their session timed out and to try again.

Session variables can be set from any page. They can be available from any of your ASP pages as long as the user does not time out. That's why I mentioned that storing the values in hidden vars on the confirm page would be good practice. Think about when and where information is available to a page/script. Since a form with enctype="multipart/form-data" does not get handled like a regular form, I also pointed out that in order to make use of the hidden variables in the form post, you have to have a server-side service like ASPSmartUpload that allows you to access the non-file parameter values. If that is not available, you have to rely on the session variables to carry over the user's information when they upload their file.
--J

jollygoodfella

2:00 am on Mar 4, 2005 (gmt 0)

10+ Year Member



Ok. So Road Runner does have an upload function. Here is the code:

<%

Set Upload = Server.CreateObject ("Persits.Upload.1")
Count = Upload.SaveVirtual ("/data/")

Set Upload = Nothing
%>
<% = Count %> file(s) uploaded.

Its quite simple, but the tech told me that this function only uploads the data to the "/data" folder of the website. How would I send that file via email? My client would like to have up to 5 images uploaded. That shouldn't be tough at all as I would only have to add the additional fields on the previous page. So I know I can handle that part of it:)

I wonder if there is a way, in order to keep the "data" folder clean (as I only have 10 megs of space for that folder), to remove the attachment once it gets sent? Maybe that's a bit much.

If we can't get the email to get emailed, maybe we can at least get the file names of the images sent via email so that my client could login to the "data" folder and just download the images.

Thanks again and I'll play around with this until I get too frustrated, as that normally happens :o)

-Mark

Ultraseeker

2:39 am on Mar 4, 2005 (gmt 0)

10+ Year Member



See if they have any sample code for you...
One thing you can do (recommended) is rename/save as some unique filename - maybe with a timestamp or random string. This would help prevent files from getting overwritten. After all this is a web service. Could have several people using the thing at the same time... 10MB is very tiny. You'll run out of space before you know it. Of course, you can delete the files when the mail is sent. Shouldn't be a problem: if you can write to a file, you can delete it as well.
One thing to watch out for is the relative path vs. virtual path for the file for the attachement property. Depending on how your mail properties need to be set, I suspect you'll need to use the full path from c:/ to your /data folder.
This 59 message thread spans 2 pages: 59