ASPEmail & ASPUpload problems

K

Kelli

Hi there,

I'm wondering if someone can have a quick look at my code and see if
there's anything that I've done wrong. This silly script is driving
me crazy!


<%
DIM File, Upload, Count, Ext
DIM Mail, strMsgHeader
Set Upload = Server.CreateObject("Persits.Upload.1")
Count = Upload.SaveVirtual("/html/uploads/")


IF NOT Count=0 THEN
FOR EACH File IN Upload.Files
Ext = UCase(Right(File.Path, 3))
IF Ext <> "TXT" AND Ext <> "DOC" THEN
Response.Write Upload.Form("FirstName") & ",<br><br>"
Response.Write "Sorry, your resume " & File.Path & " is not in a .DOC
or .TXT format and has not been delivered through our system. Please
save your resume in one of these formats and resubmit it."
File.Delete
ELSE

Set File = Upload.Files("fResume")

Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "63.99.213.33"
Mail.From = Upload.Form("Email")
Mail.AddAddress "(e-mail address removed)"
Mail.Subject = "Resume"
strMsgHeader = "This email was delivered from your website." & vbCrLf
& vbCrLf
Mail.Body = strMsgHeader & "Email: " & Upload.Form("Email") & vbCrLf &
"First Name: " & Upload.Form("FirstName") & vbCrLf & "Last Name: " &
Upload.Form("LastName") & vbCrLf & "Position: " &
Upload.Form("Position") & vbCrLf & vbCrLf & "Comments: " &
Upload.Form("Comments")

IF Count > 0 THEN
Mail.AddAttachment Upload.Files(1).Path

On Error Resume Next
Mail.Send
IF Err <> 0 THEN
Response.Write "There was an error sending your message. Please visit
our Contact Us page and send a message to our Webmaster to report this
error: <B>" & Err.Description & "</B>"
ELSE
Response.Write Upload.Form("FirstName") & ","
Response.Write "<p>Thank you for contacting our recruiter. Your resume
has been received and will be reviewed shortly. If we have a position
is available that matches your skills, we will contact you to schedule
an interview. We keep all resumes on file for a period of 6 months,
please feel free to resubmit your resume after this time for future
consideration.</p>"
File.Delete
END IF
END IF
END IF

NEXT
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<P>
<%
' personalize form
' displays name before your message.
strName = Request.Form("FirstName")
Response.Write strFirstName
%>,</P>

<P>Thank you for emailing us your resume.</P>

</body>
</html>
 
A

Aaron [SQL Server MVP]

Is there any possibility that you could tell us what the actual problem is?
Are you getting an error message? If so, what is it? If not, what is the
actual symptom that makes you think something is wrong?
 
K

Kelli

Yes sorry,

The only error I'm getting is the ole 500 Internal Server Error.

I've kind of abandoned that particular script for the moment and I'm
trying a simpler example taken from ASPUpload's site to see if I can
get that working. However, the err msg I'm getting from this one is:

The system cannot find the path specified.

/UploadAttachment.asp, line 19


I think I need to use the Server.MapPath, but I have no idea how to
use it. Here's my simple code example:

<html>
<head>
<title>Untitled Document</title>
</head>

<body><%
' change to address of your own SMTP server
strHost = "63.99.213.33"
' We use AspUpload component to capture uploaded file and access
other form items.
' Because of the special ENCTYPE attribute we can no longer use
Request.Form,
' we must use Upload.Form instead.
' More more info on AspUpload, visit www.aspupload.com.
Set Upload = Server.CreateObject("Persits.Upload")
Upload.IgnoreNoPost = True

' capture an upload and save uploaded files (if any) in temp
directory
Upload.Save "c:\html\upload"

' We cannot use Upload.Form or Upload.Files until Upload.Save is
called.
If Upload.Form("Send") <> "" Then
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.From = "(e-mail address removed)"
Mail.FromName = "Attachment Demo"
Mail.Host = strHost
Mail.Subject = Upload.Form("Subject")
Mail.Body = Upload.Form("Body")
Mail.AddAddress Upload.Form("To")

' Handle attached file via Upload.Files collection.
' Check if a file was ineed uploaded
If Not Upload.Files("Attachment") Is Nothing Then
Mail.AddAttachment Upload.Files("Attachment").Path
End If

' We are done. Send message
Mail.Send
Response.Write "Success!"
End If
%>
</body>
</html>

The form code is this:

<HTML>
<BODY BGCOLOR="#FFFFFF">
<!-- Note special ENCTYPE attribute: it is necessary to upload a
file-->
<FORM METHOD="POST" ACTION="UploadAttachment.asp"
ENCTYPE="multipart/form-data">
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR><TD>Enter email:</TD><TD><INPUT TYPE="TEXT" NAME="To"></TD></TR>
<TR><TD>Enter Subject:</TD><TD><INPUT TYPE="TEXT"
NAME="Subject"></TD></TR>
<TR><TD>Enter Body:</TD><TD><TEXTAREA
NAME="Body"></TEXTAREA></TD></TR>
<TR><TD>Select File Attachment:</TD><TD><INPUT TYPE=FILE
NAME="Attachment"></TD></TR>
<TR><TD COLSPAN=2><INPUT TYPE=SUBMIT NAME="Send"
VALUE="Send"></TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>


</body>
</html>

Thanks so much for any help, greatly appreciated!
Kelli
 
J

Jeff Cochran

The only error I'm getting is the ole 500 Internal Server Error.

The one answered here?

Why do I get a 500 Internal Server error for all ASP errors?
http://www.aspfaq.com/show.asp?id=2109
I've kind of abandoned that particular script for the moment and I'm
trying a simpler example taken from ASPUpload's site to see if I can
get that working. However, the err msg I'm getting from this one is:

The system cannot find the path specified.

/UploadAttachment.asp, line 19

You need to identify line 19 if you're going to tell us there's
something wrong there...

I think I need to use the Server.MapPath, but I have no idea how to
use it. Here's my simple code example:

Your code example has no Server.MapPath in it. But it's used thusly:

http://www.devguru.com/Technologies/asp/quickref/server_mappath.html

This is a problem with a component, so you may want to ask the
component publisher for help. Beyond that, strip your test to as
simple as possible, dump the form, test ASPUpload and ASPMail
separately and use files that are in the same folder as the script so
paths aren't an issue.

Jeff
 
K

Kelli

The one answered here?

Why do I get a 500 Internal Server error for all ASP errors?
http://www.aspfaq.com/show.asp?id=2109

Thanks but I do have that IE option on. I was still getting the 500
error with a couple of scripts I tried. The latest one I'm trying
however is giving me the "System cannot find path specified" error,
see below.

You need to identify line 19 if you're going to tell us there's
something wrong there...

Sorry, the err msg is "System cannot find path specified"
Which is why I think I need to use the Server.MapPath. It's not
included in my code, cuz I don't know how to implement it at this
point.
Thanks for the link to the Server.MapPath info!
Your code example has no Server.MapPath in it. But it's used thusly:

http://www.devguru.com/Technologies/asp/quickref/server_mappath.html

This is a problem with a component, so you may want to ask the
component publisher for help. Beyond that, strip your test to as
simple as possible, dump the form, test ASPUpload and ASPMail
separately and use files that are in the same folder as the script so
paths aren't an issue.

The whole issue I think is the fact thatI cannot get the uploaded
attachment part of the form working. Using files that are in the same
folder as the script seems pointless to me, because I need to be able
to get the script/form to work with files that the user wil be
uploading.
 
J

Jeff Cochran

Thanks but I do have that IE option on. I was still getting the 500
error with a couple of scripts I tried. The latest one I'm trying
however is giving me the "System cannot find path specified" error,
see below.



Sorry, the err msg is "System cannot find path specified"
Which is why I think I need to use the Server.MapPath. It's not
included in my code, cuz I don't know how to implement it at this
point.

You still would need to tell us what line 19 is...

My guess is it's the c:\..... path in your code (snipped from your
reply so I can't be much more specific...) and that path either not
existing or not having correct permissions for the anonymous user
account.
Thanks for the link to the Server.MapPath info!

The whole issue I think is the fact thatI cannot get the uploaded
attachment part of the form working. Using files that are in the same
folder as the script seems pointless to me, because I need to be able
to get the script/form to work with files that the user wil be
uploading.

Then you get to guess where the error may be instead of breaking the
parts out and testing individually.

Think of it this way:

You have a computer and a new 21" LCD display (lucky you!). But you
connect them and there's no image. You could swap an old 15" CRT for
the new display to test if anything is coming from the computer, but
since you want to use the new display you see no sense in testing with
a different display. It's called troubleshooting... :)

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top