Forum Moderators: phranque
Thanks so much in advance for any advice or help provided!
Here's my original form that works other than getting the file to upload:
<%
tType=request("Type")
email=request.form("email")
select case tType
case else
msgName=name
msgTo=email
msgBody=""
CloseOnSend=True
end select
MailerError=""
if request.form("send")>"" then
cr=chr(13)& chr(10)
name=request.form("name")
email=request.form("email")
subject=request.form("subject")
select case request("Type")
<snip>
CoID=false
%>
<html>
<head><LINK REL="stylesheet" TYPE="text/css" HREF="../_includefiles/mainstyle.css">
<title>Customer Support Case Email Form</title>
<snip>
</head>
<body bgcolor="#FFFFFF">
<form NAME="mainform" method="post" onsubmit="validate();" runat="server"><% if tType="" then %>
<table width="550">
<tr><td>
<h2><img src="../images/logo.gif"><br><br><br>
Customer Support Case Email Form</h2>
Complete the following form to enter a support case with Cheetah's Customer Support Department.
<snip>
<tr><td><input type="submit" value="Send" name="send" runat="server"> <input type="Reset" value="Clear"></td></tr></table>
<% end if %></form>
</body>
</html>
[edited by: txbakers at 3:32 am (utc) on June 8, 2005]
[edit reason] snipped long code [/edit]
<html>
<head><LINK REL="stylesheet" TYPE="text/css" HREF="../_includefiles/mainstyle.css">
<title>Customer Support Case Email Form</title>
<snip>
</head>
<body bgcolor="#FFFFFF">
<form NAME="mainform" method="post" onsubmit="validate();" runat="server" ENCTYPE="multipart/form-data" ACTION="/scripts/aspSmartUpload/supportformresults.asp">
<table width="550">
<tr><td>
<h2><img src="../images/logo.gif"><br><br><br>
Customer Support Case Email Form</h2>
Complete the following form to enter a support case with Cheetah's Customer Support Department.
<snip>
</form>
</body>
</html>
And here's the asp file:
<%
tType=request("Type")
email=request.form("email")
MailerError=""
if request.form("send")>"" then
cr=chr(13)& chr(10)
name=request.form("name")
email=request.form("email")
subject=request.form("subject")
<snip>
<%
Set myRecordSet = Server.CreateObject("adodb.recordset")
myRecordSet.Open
Set myUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
myUpload.DownloadField(myRecordSet("FILE"))
myRecordSet.Close
Set myRecordSet = nothing
%>
[edited by: txbakers at 3:43 am (utc) on June 8, 2005]
[edit reason] snipped long code [/edit]
You mentioned you were not really a Tech person, but it looks like you did a great job with that. The ASP Upload component and related code is not something for beginners, so Kudos to you for getting as far as you did!
As for your issue, I think - but not certain - that the problem lies in the red lines above. When you send the enctype as binary and use the component, the "request" object goes away and you have to use the "upload" object.
You discovered that in the "impossible" vs. "possible" section of your code and I think it carries through with all the ASP code.
One trick to doing something like this is to comment out the actual Executes and Redirects so that you stay on that page. Then, put in a whole bunch of "Response.Write" lines to check your variables and functions. You might find out which one is failing and not sending a value that you expect. Give that a try and let us know WHEN you solve it. I'm confident that you will, you have a great start here.
In your case, I would use the ASPUpload to put the file on the server first, then retrieve it as I'm doing. I might be using a different mailing component that you are, so the syntax might be different:
var Mailer = Server.CreateObject("SMTPsvg.Mailer");
Mailer.FromName = "myname";
Mailer.FromAddress = "me@example.com";
Mailer.RemoteHost = "mail.xample.com";
Mailer.Subject = "the subject";
Mailer.AddRecipient( "The Recipient","you@example.com");
Mailer.BodyText = "Text Here";
Mailer.AddAttachment ("E:\\directory\\file.txt");
Mailer.SendMail();
Mailer = null;
I'm also doing it in javascript, yours might be in VB so again, the syntax would be different.
Hope that helps you. For your form, everything looked fine. don't try to mix your operations. first get the file uploaded to the server. Then worry about the email,then the attachment.
A Computer program or script can only process on command at a time. If you need to, write it so it processes one and stop, then add another, etc. etc.
Thanks again! It feels good to get a little closer to making this work. Next, I'm going to work on getting the code in the right order, like you suggested.
Any suggestions on this?
<%
' Variables
' *********
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload
' ******
mySmartUpload.Upload
'Now lets get some values for the variables from the form
MyCompany = Request.Form("MyCompany")
etc.
'Now lets build the body of the email from the data in the form
MyBody = MyBody & "Company Name: "& MyCompany & vbcrlf
etc.
'Now lets put the variables and other information we need into the mailing script
mailTo= Request.Form("mailTo") & "name@example.com"
Subject= "Customer Support Case Email Form"
Message= Request.Form("Message")
Set Mailer = Server.CreateObject ("SMTPsvg.Mailer")
Mailer.FromName = MyName
Mailer.FromAddress = MyEmail
Mailer.RemoteHost = "mail.example.com"
Mailer.Subject = "Customer Support Case Email Form"
Mailer.BodyText = MyBody
Mailer.AddRecipient mailTo, mailTo
Mailer.ReturnReceipt = false
Mailer.ConfirmRead = false
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
Response.Write "Your message was not sent."
Response.Write Mailer.Response
END IF
%>
[edited by: txbakers at 2:09 pm (utc) on June 10, 2005]
[edit reason] examplified, trimmed [/edit]
Also, please don't post your personal emails/domain here.
The only other thing I can suggest is to not do so much at the same time. Get the form to submit with only field, and only one line of text.
You need to isolate you error.
ALSO, use Internet Explorer and do the following:
Tools > Internet Options > Advanced >
UNCHECK "Show friendly HTTP error messages"
this will give you the line number of the first error the script encounters and you can start debugging.