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]

jollygoodfella

10:40 pm on Mar 4, 2005 (gmt 0)

10+ Year Member



Yeah I know now to save the working file as something other than the original:)

I did give you the sample code for the upload and the form itself works just like how we setup the other form, so that's no problem:)

I have to Dim out the upload files and use those basically as regular variables correct? I'll play around with this more on Sunday:)

Mark

Ultraseeker

4:41 am on Mar 5, 2005 (gmt 0)

10+ Year Member



Using the Dim statement is good coding practice. It's not necessary unless you use the Option Explicit statement.
Since you're uploading the file and mailing the message/attachements from the same ASP page you should be able to just use regular vars to handle the files.

After all this, I really hope you get it working.
Cheers,
--J

jollygoodfella

3:43 pm on Mar 5, 2005 (gmt 0)

10+ Year Member



Me too:) I'll find out tomorrow. Going to Chicago for the day today...

jollygoodfella

1:37 am on Mar 7, 2005 (gmt 0)

10+ Year Member



Well I have looked at the test code that RR had for simply uploading files to server under the "/data" folder...but hence no luck.

Whever I remove the "multipart/form-data" code from the confirm page (where also I have the file input) I receive ALL of the information. But when I add the "multipart/form-data" I do not get any user imputted information?

Any ideas? I know you touched on this before and I must have read through everything you said 10 times. I just want this to work:)

Thank you for your help...

Ultraseeker

3:02 am on Mar 7, 2005 (gmt 0)

10+ Year Member



Your confirmation page should just have the tag
<form action="uploadmailer.asp" name="submitform" method="post" enctype="multipart/form-data"> to allow files to be uploaded. Forget about using hidden variables. Unless RR's upload service allows you to access them. But in this case, just use the session variables and set them here.

On the final upload/mailer page you need to just use the session variables that you set on the confirmation page: Session("myFirstName") and the others to set your mail message properties. Treat is as a regular file upload first. It might be a good idea to get that part working first. If you can successfully upload a file, then see if you can use a test file to mail it out as an attachment using hard-coded values for the mail message. If that works, then try it with the session variables, going through your confirmation page...

jollygoodfella

12:20 am on Mar 8, 2005 (gmt 0)

10+ Year Member



Don't I need the hidden variables so they get passed through to the mailer?

Ok here is the code I am using (hopefully for the final time :) )

Confirm Page:
::::::::::

<form action="orderit2.asp" method="post" name="submit">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><b><font color="#660000" size="3" face="Arial, Helvetica, sans-serif">Plaque Sizes and Stand: </font></b></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font face="Arial, Helvetica, sans-serif" size="2">6" X 8"</font> </b></td>
<td><font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Myplaque_6x8_quantity" value="<%= Myplaque_6x8_quantity %>">
<%= Myplaque_6x8_quantity %> </font></td>
</tr>
<tr>
<td><b><font face="Arial, Helvetica, sans-serif" size="2">8" X 10"</font> </b></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Myplaque_8x10_quantity2" value="<%= Myplaque_8x10_quantity2 %>">
<%= Myplaque_8x10_quantity2 %></font></td>
</tr>
<tr>
<td><b><font face="Arial, Helvetica, sans-serif" size="2">10.5" X 13"</font> </b></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Myplaque_10_5x13_quantity3" value="<%= Myplaque_10_5x13_quantity3 %>">
<%= Myplaque_10_5x13_quantity3 %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Plaque Stand </font></b></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Myplaque_stand_quantity" value="<%= Myplaque_stand_quantity %>">
<%= Myplaque_stand_quantity %></font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Plaque Text: </font></b></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mytext_wanted_on_plaque" value="<%= Mytext_wanted_on_plaque %>">
<%= Mytext_wanted_on_plaque %></font></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Plaque Design: </font></b></td>
<td> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Myplaque_design" value="<%= Myplaque_design %>">
<%= Myplaque_design %></font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td colspan="2"><b><font size="2" face="Arial, Helvetica, sans-serif">Attachments:</font></b></td>
</tr>
<tr>
<td colspan="2"><input name="file1" type="file" id="file1"></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td colspan="2"><b><font color="#660000" size="3" face="Arial, Helvetica, sans-serif">Mailing (ship to) Address</font></b></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td width="166"><b><font size="2" face="Arial, Helvetica, sans-serif">First Name: </font></b></td>
<td width="334">
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mymailing_first_name" value="<%= Mymailing_first_name %>">
<%= Mymailing_first_name %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Last Name: </font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mymailing_last_name" value="<%= Mymailing_last_name %>">
<%= Mymailing_last_name %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Street Address: </font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mymailing_street_address" value="<%= Mymailing_street_address %>">
<%= Mymailing_street_address %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">City</font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mymailing_city" value="<%= Mymailing_city %>">
<%= Mymailing_city %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">State</font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mymailing_state" value="<%= Mymailing_state %>">
<%= Mymailing_state %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Zip</font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mymailing_zip" value="<%= Mymailing_zip %>">
<%= Mymailing_zip %></font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td colspan="2"><b><font color="#660000" size="3" face="Arial, Helvetica, sans-serif">Billing Information </font></b></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">First Name: </font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Myfirstname" value="<%= Myfirstname %>">
<%= Myfirstname %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Last Name: </font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mylastname" value="<%= Mylastname %>">
<%= Mylastname %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Email:</font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Myemail" value="<%= Myemail %>">
<%= Myemail %></font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Phone Number: </font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mybilling_phone" value="<%= Mybilling_phone %>">
<%= Mybilling_phone %></font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Shipping Type:</font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Myshipping" value="<%= Myshipping %>">
<%= Myshipping %></font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td colspan="2"><b><font color="#660000" size="3" face="Arial, Helvetica, sans-serif">Payment Information </font></b></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Payment Type: </font></b></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="hidden" name="Mypayment_type" value="<%= Mypayment_type %>">
<%= Mypayment_type %></font></td>
</tr>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Comments</font></b></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><%= Mycomments %>
<input type="hidden" name="Mycomments" value="<%= Mycomments %>">
</font></td>
</tr>
</table>
<p>
<input type="button" name="Button" value="Change" onclick="history.go(-1)">
<input type="submit" name="Submit" value="Submit">
</p>
</form>

::::::::::

OrderIt page (mailer)

::::::::::

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'First lets Dim all the variables we need
Dim MyBody
Dim Mymailing_first_name
Dim Mymailing_last_name
Dim Mymailing_street_address
Dim Mymailing_city
Dim Mymailing_zip
Dim Mymailing_state
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 Mycomments
Dim Myfile1

'Now lets get some values for the variables from the form
Myemail = Request.Form("Myemail")
Mymailing_first_name = Request.Form("Mymailing_first_name")
Mymailing_last_name = Request.Form("Mymailing_last_name")
Mymailing_street_address = Request.Form("Mymailing_street_address")
Mymailing_city = Request.Form("Mymailing_city")
Mymailing_zip = Request.Form("Mymailing_zip")
Mymailing_state = Request.Form("Mymailing_state")
Myfirstname = Request.Form("Myfirstname")
Mylastname = Request.Form("Mylastname")
Myplaque_6x8_quantity = Request.Form("Myplaque_6x8_quantity")
Myplaque_8x10_quantity2 = Request.Form("Myplaque_8x10_quantity2")
Myplaque_10_5x13_quantity3 = Request.Form("Myplaque_10_5x13_quantity3")
Myplaque_stand_quantity = Request.Form("Myplaque_stand_quantity")
Mytext_wanted_on_plaque = Request.Form("Mytext_wanted_on_plaque")
Myplaque_design = Request.Form("Myplaque_design")
Mybilling_phone = Request.Form("Mybilling_phone")
Myshipping = Request.Form("Myshipping")
Mypayment_type = Request.Form("Mypayment_type")
Mycomments = Request.Form("Mycomments")
Myfile1 = Request.Form("Myfile1")

'Now lets build the body of the email from the data in the form
MyBody = MyBody & "Mailing First Name: "& Mymailing_first_name & vbcrlf
MyBody = MyBody & "Mailing Last Name: "& Mymailing_last_name & vbcrlf
MyBody = MyBody & "Mailing Street Address: "& Mymailing_street_address & vbcrlf
MyBody = MyBody & "Mailing City: "& Mymailing_city & vbcrlf
MyBody = MyBody & "Mailing Zip: "& Mymailing_zip & vbcrlf
MyBody = MyBody & "Mailing State: "& Mymailing_state & vbcrlf & vbcrlf
MyBody = MyBody & "First Name: "& Myfirstname & vbcrlf
MyBody = MyBody & "Last Name: "& Mylastname & vbcrlf
MyBody = MyBody & "Email: "& Myemail & vbcrlf & vbcrlf
MyBody = MyBody & "6 x 8 Plaque QTY: "& Myplaque_6x8_quantity & vbcrlf
MyBody = MyBody & "8 x 10 Plaque QTY: "& Myplaque_8x10_quantity2 & vbcrlf
MyBody = MyBody & "10.5 x 13 Plaque QTY: "& Myplaque_10_5x13_quantity3 & vbcrlf
MyBody = MyBody & "Plaque Stand QTY: "& Myplaque_stand_quantity & vbcrlf
MyBody = MyBody & "Text Wanted on Plaque: "& Mytext_wanted_on_plaque & vbcrlf
MyBody = MyBody & "Plaque Design: "& Myplaque_design & vbcrlf & vbcrlf
MyBody = MyBody & "Shipping: "& Myshipping & vbcrlf & vbcrlf
MyBody = MyBody & "Billing Phone: "& Mybilling_phone & vbcrlf & vbcrlf
MyBody = MyBody & "Comments: " & Mycomments & vbcrlf & vbcrlf
MyBody = MyBody & "Attachment 1: " & Myfile1

'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@sample.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
%>

::::::::::

The code I got from the Techs from RR is this:

<%

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

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

It works well on the testing page they had, but that simply uploads the files to the server. I guess I'm not sure if I can use that code for what I'm trying to do or not, if I can use it I'm not sure where to put it.

The main thing I'm seeing her is that anytime I use "multipart/form-data" on my confirmation page no user inputting data gets sent through. Am I still using the wrong variable types? I must be.

I just can't believe how much of a pain in the arse I have been as a result of this ASPUpload issue. I am sure everyone is getting sick of me and this issue as I know I definately would! I work in tech support and I know that I get extremely annoyed by people who cannot figure something out after repeated help.

But it would certainly mean a whole lot to me if I can finally lay this to rest!

Thanks again and I am sorry that I am a knucklehead when it comes to this.

Cordially,

-Mark

Ultraseeker

2:42 am on Mar 8, 2005 (gmt 0)

10+ Year Member



I edited your code with comments to point out the main things that need to be fixed. I don't have a server where I can test this code, so I did the best I could:

- set session variables on the confirm page for all vars that you want to use in the mail message.
- you must use the multipart form attribute
- session variables can be set once and then reused on other pages without having to be set again, unless the user's session times out. that's why you don't need to use the hidden vars. won't work anyway with multipart.
- you have to use the file collection to access the properties of the files being uploaded.
- make sure you read the documentation for asp upload if you run into trouble. see link in the code comments:

Confirm Page:
::::::::::
<%
'set session variables - do this for every variable you want to carry over:
' do not include file names that you want to upload
Dim Mymailing_first_name, missingParam

Mymailing_first_name = trim(Request.Form("Mymailing_first_name"))

'do this for all required parameters
if (len(Mymailing_first_name) = 0) then
missingParam = missingParam + "First Name<br>"
end if

if (missingParam) then
response.redirect("orderit.asp?missingParam=" + server.urlencode(missingParam))
else
'do this for all the vars:
session("Mymailing_first_name") = Mymailing_first_name

end if
%>

<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><b><font color="#660000" size="3" face="Arial, Helvetica, sans-serif">Plaque Sizes and Stand: </font></b></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font face="Arial, Helvetica, sans-serif" size="2">6" X 8"</font> </b></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><%= Myplaque_6x8_quantity %> </font></td>
</tr>
....
<tr>
<td colspan="2"><b><font size="2" face="Arial, Helvetica, sans-serif">Attachments:</font></b></td>
</tr>
<tr>
<form action="orderit2.asp" method="post" enctype="multipart/form-data" name="submit">
<td colspan="2"><input name="file1" type="file" id="file1"></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td colspan="2"><b><font color="#660000" size="3" face="Arial, Helvetica, sans-serif">Mailing (ship to) Address</font></b></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td width="166"><b><font size="2" face="Arial, Helvetica, sans-serif">First Name: </font></b></td>
<td width="334">
<font size="2" face="Arial, Helvetica, sans-serif"> <%= Mymailing_first_name %>
</font></td>
</tr>
....
</table>
<p>
<input type="button" name="Button" value="Change" onclick="history.go(-1)">
<input type="submit" name="Submit" value="Submit">
</p>
</form>

::::::::::

OrderIt page (mailer)

::::::::::

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

'Now lets build the body of the email from the data in the form
MyBody = MyBody & "Mailing First Name: "& session("Mymailing_first_name") & vbcrlf
'...
''MyBody = MyBody & "Attachment 1: " & Myfile1 -- can't do that either, see docs on how to add this to the body

''Myfile1 = Request.Form("Myfile1") -- this is wrong, you cannot do that

'''see docs for asp upload: [aspupload.com...]

Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.OverwriteFiles = False 'prevents overwriting files
Count = Upload.Save("c:\useraccountfolder\data") ' the path to your /data folder from c:\
'if an attachment is required, you can flag and handle error: if (Count = 0) then do something

'Now lets put the variables and other information we need into the mailing script
' These vars need to be set from the session variables, not the form post
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@sample.com"
Mailer.Subject = "Your Order from FotoPlaques.com " & Subject
Mailer.BodyText = MyBody

'add attachments here:
For Each File in Upload.Files
Mailer.AddAttachment File.Path
Next

'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

Set Upload = Nothing

Response.Write "Your message was not sent."
Response.Write Mailer.Response
END IF
%>

::::::::::

jollygoodfella

2:51 am on Mar 9, 2005 (gmt 0)

10+ Year Member



Good news...I have the form working but the upload section isn't uploading the data. But I am using the encytpe on the confirmation page and all the user inputted data is being sent correctly:) So that's one thing down:)

The problem is I am not sure if this is right:

Count = Upload.Form("d:\webs\fotop1\data\")

I can't use the Upload.Save as that is turned off for the website. When I do use it I get an error telling me to use "Upload.SaveVirtual" instead. But when I do use that I get " Persits.Upload.1 error '800a0001' Request.BinaryRead Failed. "

I did some research on that error and the site I found says to use " Upload.Form" instead. I have read some documentation about that and it seems so foreign to me. I added that in place of the Upload.SaveVirtual and the form still does send, but the attachment never gets uploaded.

Any ideas anyone?

-Mark

Ultraseeker

3:47 am on Mar 9, 2005 (gmt 0)

10+ Year Member



If the RR techs told you to use the virtual path, then that's what you should try first.
I think you should also make sure that whatever the target upload directory is (/data or whatever) is writable by all. This is necessary for the web application to be able to write files to a directory. Since you can't do that yourself using chmod on IIS, you'll need to ask them to make that directory writable by the web server.

Also, try this to look at your environment variables:
Paste this in an .asp page and upload to your server. Name it something like serverenv.asp, in the body of the html.

<h3>Request Vars</h3>
<%
For each element in Request.ServerVariables
%>
Request.ServerVariables("<%= element %>") = <%= Request.ServerVariables(element) %>
<br>
<%
Next%>

You'll see all kinds of things like:
Request.ServerVariables("APPL_PHYSICAL_PATH") = C:\Inetpub\wwwroot\Htdocs\www.yourdomain.com\
I use that all the time to refer to paths. It's easy to forget...

jollygoodfella

4:21 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



Well I know that the "data" folder is writeable as the RR tech guys had a simple form that did upload the attachments to the "data" folder.

I asked them more about "SaveVirtual" and the only thing they told me was that SaveVirtual uses virtual paths and not absolute paths like the "Save" function uses...that of which I already knew.

The problem is when I used "SaveVirtual" I get this error:

Persits.Upload.1 error '800a0001'

Request.BinaryRead failed.

/cgi-bin/orderit2.asp, line 71

I did research on that and the "fix" was to use "Upload.Form" whick doesn't give me any errors...but doesn't upload the file either.

Any Ideas?

Ultraseeker

1:36 am on Mar 12, 2005 (gmt 0)

10+ Year Member



"...the RR tech guys had a simple form that did upload the attachments to the "data" folder."

What did that form look like? Did it use enctype="multipart/form-data"?

Ask the RR tech to send you the sample files, including the target file for the form action. At least that will tell you what works.

Is the /data in your root directory? Can you see it using an ftp client?

jollygoodfella

9:35 am on Mar 12, 2005 (gmt 0)

10+ Year Member



Here is the .html page for the RR test along with the asp page too:

html page:

<HTML>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="techtestupload.asp">
<INPUT TYPE= FILE SIZE= 60 NAME="FILE1"> <BR>
<INPUT TYPE= FILE SIZE= 60 NAME="FILE2"> <BR>
<INPUT TYPE= FILE SIZE= 60 NAME="FILE3"> <BR>
<INPUT TYPE="SUBMIT" VALUE="Upload!">
</FORM>
</BODY>
</HTML>

asp page:

<%

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

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

Its pretty straight forward. My thought was that maybe some of the variables we are using aren't compatible with the SaveVirtual part.

"data" is not the root directory and I can see this folder via FTP. The RR form works great, but trying to take their information and add it to my form is where the problem lies.

-Mark

Ultraseeker

9:21 pm on Mar 12, 2005 (gmt 0)

10+ Year Member



reworked with virtual path. According to the docs you should be able to use the Upload.Files collection to set the attachments...
If this still does not work, see if the file is actually uploaded to the /data directory. If it exists, then try sending a test email with an attachment using the file from the /data dir.

Confirm Page:
::::::::::
<%
'set session variables - do this for every variable you want to carry over:
' do not include file names that you want to upload
Dim Mymailing_first_name, missingParam

Mymailing_first_name = trim(Request.Form("Mymailing_first_name"))

'do this for all required parameters
if (len(Mymailing_first_name) = 0) then
missingParam = missingParam + "First Name<br>"
end if

if (missingParam) then
response.redirect("orderit.asp?missingParam=" + server.urlencode(missingParam))
else
'do this for all the vars:
session("Mymailing_first_name") = Mymailing_first_name

end if
%>

<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><b><font color="#660000" size="3" face="Arial, Helvetica, sans-serif">Plaque Sizes and Stand: </font></b></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td><b><font face="Arial, Helvetica, sans-serif" size="2">6" X 8"</font> </b></td>
<td><font size="2" face="Arial, Helvetica, sans-serif"><%= Myplaque_6x8_quantity %> </font></td>
</tr>
....
<tr>
<td colspan="2"><b><font size="2" face="Arial, Helvetica, sans-serif">Attachments:</font></b></td>
</tr><form action="orderit2.asp" method="post" enctype="multipart/form-data">
<tr>
<td colspan="2"><input name="file1" type="file" size="65"></td>
</tr>
<tr>
<td colspan="2"><input name="file2" type="file" size="65"></td>
</tr>
<tr>
<td colspan="2"><input name="file3" type="file" size="65"></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td colspan="2"><b><font color="#660000" size="3" face="Arial, Helvetica, sans-serif">Mailing (ship to) Address</font></b></td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
</tr>
<tr>
<td width="166"><b><font size="2" face="Arial, Helvetica, sans-serif">First Name: </font></b></td>
<td width="334">
<font size="2" face="Arial, Helvetica, sans-serif"> <%= Mymailing_first_name %>
</font></td>
</tr>
....
</table>
<p>
<input type="button" name="Button" value="Change" onclick="history.go(-1)">
<input type="submit" name="Submit" value="Submit">
</p>
</form>

::::::::::

OrderIt page (orderit2.asp)

::::::::::
<%
'First lets Dim all the variables we need
Dim MyBody
Dim Mymailing_first_name
'...
Dim Myfile1

'Now lets build the body of the email from the data in the form
MyBody = MyBody & "Mailing First Name: "& session("Mymailing_first_name") & vbcrlf
'...
''MyBody = MyBody & "Attachment 1: " & Myfile1 -- can't do that either, see docs on how to add this to the body

''Myfile1 = Request.Form("Myfile1") -- this is wrong, you cannot do that

'''see docs for asp upload: [aspupload.com...]

Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.OverwriteFiles = False 'prevents overwriting files
Count = Upload.SaveVirtual ("/data/")
'if an attachment is required, you can flag and handle error: if (Count = 0) then do something

'Now lets put the variables and other information we need into the mailing script
' These vars need to be set from the session variables, not the form post
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@sample.com"
Mailer.Subject = "Your Order from FotoPlaques.com " & Subject
Mailer.BodyText = MyBody

'add attachments here:
For Each File in Upload.Files
Mailer.AddAttachment File.Path
Next

'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

Set Upload = Nothing

Response.Write "Your message was not sent."
Response.Write Mailer.Response
END IF
%>

jollygoodfella

10:29 pm on Mar 12, 2005 (gmt 0)

10+ Year Member



Well I can now NOT use Upload.Files. I still get an error saying to use SaveVirtual again. This sucks. I'll have to look more at:

[aspupload.com...]

Man I'm getting tired of researching this you know? It wouldn't be so bad if this hadn't taken me 3 weeks or more to get to this point. But I will keep working on it and if anyone has some other work arounds that would certainly be appreciated!

Thank you Ultra for all your help thus far:)

-Mark

jollygoodfella

10:31 pm on Mar 12, 2005 (gmt 0)

10+ Year Member



Is there anyway I can incorporate this code?

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

That is what RR was using. Are the variables through the session() variables causing problems with working with the Upload.SaveVirutal? I guess I just don't understand how RR can use that on their form and I can't uee that with mine.

-Mark

Ultraseeker

4:13 am on Mar 13, 2005 (gmt 0)

10+ Year Member



the last bit of code I posted does use
Count = Upload.SaveVirtual ("/data/")

I don't think using session variables would interfere with the upload function or the mail function, all you're doing with them is setting and getting values that aren't related to the upload service.

This should work. So you're saying you cannot access the Files collection?

jollygoodfella

7:26 am on Mar 13, 2005 (gmt 0)

10+ Year Member



This is the last bit of code on the OrderIt2 page

:::::::::::

Set Upload = Server.CreateObject("Persits.Upload.1")
Count = Upload.SaveVirtual ("/data/")
For Each File in Upload.Files
Response.Write "File Uploaded Successfully : " & File.Path & " " & File.Size &" bytes"
Next

'Set Upload = Server.CreateObject("Persits.Upload.1")
'Upload.OverwriteFiles = False 'prevents overwriting files
'Count = Upload.SaveVirtual "/"
'Response.Write Count & " file(s) uploaded to FotoPlaques.com"
'if an attachment is required, you can flag and handle error: if (Count = 0) then do something

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

Set Mailer = Server.CreateObject ("SMTPsvg.Mailer")
Mailer.FromName = "OrderIt!"
Mailer.FromAddress = "orderit@fotoplaques.com"
Mailer.Subject = "Your Order from FotoPlaques.com " & Subject
Mailer.BodyText = MyBody

'add attachments here:
For Each File in Upload.Files
Mailer.AddAttachment File.Path
Next

'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

Response.Redirect "../thankyou.asp"
ELSE

' If there was an error in sending an email, this code will output to the screen
Set Mailer = Nothing

Set Upload = Nothing

Response.Write "Your message was not sent."
Response.Write Mailer.Response
END IF
%>

:::::::::::

When I use "Count = Upload.SaveVirtual ("/data/")" I get this error:

Persits.Upload.1 error '800a0001'

Request.BinaryRead failed.

/cgi-bin/orderit2.asp, line 67

As I stated before I did some research on the topic and was instructed to use "Upload.Form". I tried "Upload.Files" but I still get errors. That made me think that maybe something else is wrong with the code...

That doesn't seem quite right though either as if I hide this code:

Set Upload = Server.CreateObject("Persits.Upload.1")
Count = Upload.SaveVirtual ("/data/")
For Each File in Upload.Files
'Response.Write "File Uploaded Successfully : " & File.Path & " " & File.Size &" bytes"
Next

and this code:

'add attachments here:
For Each File in Upload.Files
Mailer.AddAttachment File.Path
Next

The mail form goes through without a problem. But when I don't hide it in the code I get those errors. Maybe I am using the wrong terminology or statements. But I can't seem to find anything concrete about this problem.

Any Ideas once again?

-Mark

Ultraseeker

8:24 am on Mar 13, 2005 (gmt 0)

10+ Year Member



try getting rid of the request.form calls:
mailTo= Request.Form("mailTo") & "encryptdesigns@gmail.com"
Subject= Request.Form("Subject")
Message= Request.Form("Message")
You don't need these if you're using session vars.

According to [support.persits.com...]
If you use request.form prior to using the collection values from upload.save you'll get errors.
So remove any lines that use request.form.
Also, I'd get rid of the lines that do the response.write as well.

jollygoodfella

6:47 pm on Mar 13, 2005 (gmt 0)

10+ Year Member



Wooooooohooooooooooo!

\:D/ = dancing around like a crazy fool \:D/

That worked! The file is now uploading:)

And guess what? It also emails the attachment too!

Holy Crap! I never thought I would get to this point :):)

Thank you soooo much Ultra. I'll add you as a wonderful Partner on my site once I finish a few things:)

Wow I can't believe I finally got this working. Of course none of this would have been possible without you my friend:)

Thanks again!

-Mark

jollygoodfella

7:03 pm on Mar 13, 2005 (gmt 0)

10+ Year Member



The only thing I noticed was after I added 4 more attachment fields was that I had to remove ", missingParam" from each of the "Dim Mymailing_first_name" variables on my Confirm Page. You don't think that this will pose a problem or anything do you?

-Mark

Ultraseeker

3:07 am on Mar 14, 2005 (gmt 0)

10+ Year Member



the missingParams thing should only matter for the first two pages. None of that information is carried over to the final mailer/upload page. There are several ways you can verify that your required fields are filled in properly. One is to build up a string that lists the missing parameter names and redirects the user to the page where they can fill in the missing information (convenience thing), or you can just list them on the confirmation page without having to build the string at all, then prompt them to click back and fill them in...

The main thing is that you don't end up on the mailer/upload page with missing info that you need. So whatever method you choose to implement is up to you.
As long as it works!

Congratulations on finally making this beast come to life. Trial by fire they call it...

Cheers,
--Jeffery

jollygoodfella

11:59 pm on Mar 14, 2005 (gmt 0)

10+ Year Member



Thank you for all of your help:)

It doesn't seem like the parameters thing works as far as the error checking process goes. Is there alternate code I could use to help with the error checking? Maybe I could use some Javascript for the error checking issue too? I have used that before and that wouldn't screw with the other code I have would it?

-Mark

Ultraseeker

3:00 am on Mar 15, 2005 (gmt 0)

10+ Year Member



You can use Javascript on the first page to check required fields, however some people have Javascript turned off, so that could lead to problems.

Try to get the missingParams to work:
Just so there's no confusion:
- firstpage.asp refers to the first page where they fill in the form
- orderit.asp refers to the confirmation page
- orderit2.asp refers to the mailer/upload page

On the confirm page (orderit.asp):

Dim missinParams : misssingParams = ""

'do this for all required parameters
if (len(Mymailing_first_name) = 0) then
missingParam = missingParam + "First Name is required.<br>"
else
session("Mymailing_first_name") = Mymailing_first_name
end if

if (len(missingParam) > 0) then
response.redirect("firstpage.asp?missingParam=" + server.urlencode(missingParam))
end if

On the firstpage.asp:
Dim missingParams : missingParams = trim(Request.QueryString("missingParams"))

if (len(missingParams) > 0) then
missingParams = "Missing parameters: <br>" + missingParams
end if

In the body of firstpage.asp:
<%= missingParams %>

In the form fields, show values for fields that were set:
<input type="text" name="Mymailing_first_name" value="<%= session("Mymailing_first_name") %>" size="35" maxlength="100">

It is polite to fill in values in the form that they already typed in...

OnePanman

6:44 am on Mar 17, 2005 (gmt 0)



I Have followed this thread all the way through completion. I was having the EXACT SAME PROBLEM. This thread was a life saver! BUt now i have one more Delima. On the emailer response, How is it possible to send the response to the Recipient in HTML format with the attachment(s)?

IDEAS? Thanks!

Ultraseeker

9:45 pm on Mar 17, 2005 (gmt 0)

10+ Year Member



If you're using ASPMail:
[mavweb.net...]
Look at the section "How do I create a hyperlink in my message?" Basically, you have to use: Set Mailer.ContentType = "text/html"

If you're using the ASPEmail component instead, see:
[aspemail.com...]

jollygoodfella

10:30 pm on Mar 23, 2005 (gmt 0)

10+ Year Member



Hey Everyone:)

Well the form was working great for awhile and now all of a sudded the session() variables don't get sent via email. The first page (order.asp) sends the information to the 2nd page (confirm.asp) and it "appears" the information gets sent through the 3rd page (orderit.asp) which sends it to my email account. But when I check the email there are no user inputted variables. The weird thing is that the attachment does send. So that makes me think that there is something wrong with the "session("variablename")" fields.

Can anyone shed some light on this? I thought I was done before!

Thanks again:)

Mark

BTW: my site is almost done Ultra so I'll definately link your site to mine, i have had some other projects, including this aspmail form, so i haven't finished some minor things off yet.

Ultraseeker

1:52 am on Mar 24, 2005 (gmt 0)

10+ Year Member



"Well the form was working great for awhile and now all of a sudded the session() variables don't get sent via email. ... But when I check the email there are no user inputted variables. The weird thing is that the attachment does send. So that makes me think that there is something wrong with the "session("variablename")" fields. "

Do you have a version that worked? Sounds like you may need to look at how you're getting the session vars and setting mailer values. In particular, things like spelling and variable scope can be easy to miss.
One thing that can help a lot is print out the values for the main variables as they get set to make sure you are getting what you expect (response.write()).

I'll take another look at your last two pages of code if you want to. Just remove the sensitive information from the scripts.

jollygoodfella

3:07 am on Mar 24, 2005 (gmt 0)

10+ Year Member



The thing is I didn't change anything. I only recently add an image to display sizes and I'm certain that the form worked after that too. I'll go through things again, but I'm 99% positive that everything worked fine before.

-Mark

jollygoodfella

12:35 am on Mar 28, 2005 (gmt 0)

10+ Year Member



ok so this message board sucks and won't let me paste my response. so i'm going to OM you Ultra and see if we can get this rockin:)
This 59 message thread spans 2 pages: 59