Discuss Shadow Uploader - Email the uploaded file in the ASP Development forum on ASP Free. Shadow Uploader - Email the uploaded file ASP Development forum discussing ASP related topics including coding practices, ASP tips, and more. Active Server Pages (ASP) enables you to empower your HTML pages dynamically with robust scripting options.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.
Ok ! The code works perfect !!!
But what should I do in order to e-mail the files uploaded ?
What I mean is that when the files are uploaded I also want to be e-mailed at the same time...
So far I had tried this...
http://forums.aspfree.com/asp-development-5/upload-files-and-send-e-mail-using-cdosys-133826.html
I could really use some help with this !
Thanks
Last edited by Shadow Wizard : January 18th, 2007 at 06:25 AM.
Posts: 5
Time spent in forums: 1 h 20 m 49 sec
Reputation Power: 0
Getting Upload Script to Work with CDO.SYS
Hello Shadow,
Was trying to implement your ShadowUpload Script into my existing form and e-mail the result to a user with the attached file. But somehow I keep running into the following error. Could you be so kind as to be of assistance?
My Code :
ApplyJob.asp (Where by original form comes from)
Code:
<form action="EmailSent.asp" method="post" enctype="multipart/form-data" name="frmJobApplication" id="frmJobApplication">
<table width="700" border="0" align="center">
<tr>
<td><span class="style11">Job ID : </span></td>
<td><%=(Recordset1.Fields.Item("JobsID").Value)%> <input name="txtJobID" type="hidden" id="txtJobID" value="<%=(Recordset1.Fields.Item("JobsID").Value)%>"></td>
</tr>
<tr>
<td width="124"><span class="style11">Position : </span></td>
<td width="460"><%=(Recordset1.Fields.Item("Position").Value)%> <input name="txtPosition" type="hidden" id="txtPosition" value="<%=(Recordset1.Fields.Item("Position").Value)%>"></td>
</tr>
<tr>
<td><span class="style11">Company Name : </span></td>
<td><%=(Recordset1.Fields.Item("CompanyName").Value)%>
<input name="txtCompanyName" type="hidden" id="txtCompanyName" value="<%=(Recordset1.Fields.Item("CompanyName").Value)%>"></td>
</tr>
<tr>
<td><span class="style11">Your E-mail : </span></td>
<td><input name="txtEmail" type="text" id="txtEmail" size="70"></td>
</tr>
<tr>
<td><span class="style11">Subject : </span></td>
<td><input name="txtSubjectFake" type="text" id="txtSubjectFake" value="Application for the post of <%=(Recordset1.Fields.Item("Position").Value)%> via JobsWalk.com" size="70">
<input name="txtSubject" type="hidden" id="txtSubject" value="Application for the post of <%=(Recordset1.Fields.Item("Position").Value)%> via JobsWalk.com"></td>
</tr>
<tr>
<td><span class="style11">Cover Letter : </span></td>
<td><textarea name="txtCoverLetter" cols="70" rows="15" id="txtCoverLetter">Dear Sir/Madam,
I wish to apply for the position above, as advertised on JobsWalk.com on <%=(Recordset1.Fields.Item("DateRegistered").Value)%>.
[Please add the rest of your message here.]
Thank you.
Sincerely
[Your Name]</textarea></td>
</tr>
<tr>
<td><span class="style11">Attach Resume </span></td>
<td><span class="style11">
<input name="fileAttachResume" type="file" id="fileAttachResume" size="60">
<br>
*Kindly save your resume in your C:\ Drive before attaching. </span></td>
</tr>
<tr>
<td><span class="style11"></span></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
EmailSent.asp (Where I intend to e-mail with attachment)
Code:
<!-- #include file="ShadowUploader.asp" -->
<%
Set objUpload=New ShadowUpload
For x=0 To objUpload.FileCount-1
Response.Write("file name: "&objUpload.File(x).FileName&"<br />")
Response.Write("file type: "&objUpload.File(x).ContentType&"<br />")
Response.Write("file size: "&objUpload.File(x).Size&"<br />")
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
Response.Write("file saved successfully!")
Response.Write("<hr />")
Next
%>
<%
If Trim(Request.Form("Submit")) <> "" Then
Set myMail = CreateObject("CDO.Message")
myMail.Subject = Trim(Request.Form("txtSubject"))
myMail.From = Trim(Request.Form("txtEmail"))
myMail.To = "kevinloh@jobswalk.com"
myMail.TextBody = Trim(Request.Form("txtCoverLetter"))
myMail.AddAttachment Trim(objUpload("fileAttachResume"))
'myMail.AddAttachment Trim(Request.Form("fileAttachResume"))
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 2
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "202.75.48.50"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 25
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 1
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "mail@jobswalk.com"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "abc123"
myMail.Configuration.Fields.Update
myMail.Send
Set myMail = nothing
End If
%>
Error Message :
Technical Information (for support personnel)
Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied
/jobs/ShadowUploader.asp, line 283
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
Page:
POST 22226 bytes to /jobs/EmailSent.asp
POST Data:
error '80020009'
Exception occurred.
/iisHelp/common/500-100.asp, line 223
==============================================
Apologies if this post is too long. But really do need your help.
Thanks
Last edited by Shadow Wizard : December 25th, 2006 at 06:14 AM.
Reason: added [Code] and [/Code] tags around code - please do that yourself next!
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
you must have folder called "Uploads" under the folder
where the ASP script is located, and over this folder
grant Read/Write/Execute permissions to the IUSR
user account of the web server.
Posts: 5
Time spent in forums: 1 h 20 m 49 sec
Reputation Power: 0
Code Works with IIS Locally but not remotely?
Quote:
Originally Posted by Shadow Wizard
you must have folder called "Uploads" under the folder
where the ASP script is located, and over this folder
grant Read/Write/Execute permissions to the IUSR
user account of the web server.
full guide about setting permissions can be found here: (URL address blocked: See forum rules)
(just give the permissions to the whole folder instead of single MDB file)
Dear Shadow Wizard,
Managed to get your code and my CDO.SYS e-mail to work properly when I test it on my own desktop with IIS after modifying the permissions as above. But when I uploaded the whole code to my hosting company. I get another error message. This time not so friendly :
<%
'changing all Request.Form to objUpload
If Trim(objUpload("Submit")) <> "" Then
Set myMail = CreateObject("CDO.Message")
myMail.Subject = Trim(objUpload("txtSubject"))
myMail.From = Trim(objUpload("txtEmail"))
myMail.To = "kevinloh@jobswalk.com"
myMail.TextBody = Trim(objUpload("txtCoverLetter"))
myMail.AddAttachment Trim(objUpload("fileAttachResume"))
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 2
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "202.75.48.50"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 25
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 1
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "mail@jobswalk.com"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "abc123"
myMail.Configuration.Fields.Update
myMail.Send
Set myMail = nothing
End If
%>
[code]
Error Message :
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.
Open the (URL address blocked: See forum rules) home page, and then look for links to the information you want.
Click the Refresh button, or try again later.
Click Search to look for information on the Internet.
You can also see a list of related sites.
HTTP 500 - Internal server error
Internet Explorer
Do U suppose it is also because of the permissions settings in my hosting server as well? Appreciate your kind wisdom.
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
in your IE browser, click Tools --> Internet Options.
go to the Advanced tab, untick the checkbox "show
friendly http error messages" and confirm.
reload the page and you shoud see real error message.
yes that's most probably due to permissions, you better
contact your host and ask them where you can store files.
Posts: 5
Time spent in forums: 1 h 20 m 49 sec
Reputation Power: 0
A more meaningful Error Message.
Quote:
Originally Posted by Shadow Wizard
in your IE browser, click Tools --> Internet Options.
go to the Advanced tab, untick the checkbox "show
friendly http error messages" and confirm.
reload the page and you shoud see real error message.
yes that's most probably due to permissions, you better
contact your host and ask them where you can store files.
Dear Shadow Wizard,
Here is the more meaningful error message once I untick the friendly error message option.
Microsoft VBScript runtime error '800a01a8'
Object required: 'm_Files'
/ShadowUploader.asp, line 18
The above doesn't look like a permission error. Any ideas?
Posts: 5
Time spent in forums: 1 h 20 m 49 sec
Reputation Power: 0
Cannot find path in Upload Script
Quote:
Originally Posted by Shadow Wizard
in your code, you're missing this line:
Code:
Set objUpload=New ShadowUpload
you must add this line before trying to read the files.
Dear Shadow,
Managed to get my web provider to change the permissions for me and added in the Set objUpload=New ShadowUpload into my script. However, now it says the following error message :
CDO.Message.1 error '80070003'
The system cannot find the path specified.
/EmailSent.asp, line 95
My code for EmailSent.asp
Code:
<%
Set objUpload=New ShadowUpload
For x=0 To objUpload.FileCount-1
' Response.Write("file name: "&objUpload.File(x).FileName&"<br />")
' Response.Write("file type: "&objUpload.File(x).ContentType&"<br />")
' Response.Write("file size: "&objUpload.File(x).Size&"<br />")
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
' Response.Write("file saved successfully!")
' Response.Write("<hr />")
Next
%>
<%
'changing all Request.Form to objUpload
If Trim(objUpload("Submit")) <> "" Then
Set myMail = CreateObject("CDO.Message")
myMail.Subject = Trim(objUpload("txtSubject"))
myMail.From = Trim(objUpload("txtEmail"))
myMail.To = "kevinloh@jobswalk.com"
myMail.TextBody = Trim(objUpload("txtCoverLetter"))
myMail.AddAttachment Trim(objUpload("fileAttachResume"))
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 2
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "202.75.48.50"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 25
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 1
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "mail@jobswalk.com"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "abc123"
myMail.Configuration.Fields.Update
myMail.Send
Set myMail = nothing
End If
%>
Line 95 :
myMail.AddAttachment Trim(objUpload("fileAttachResume"))
where fileAttachResume is the File Field Name I am trying to get from my form.
Is there anyway I can change the code in Line 95 to read from the wwwroot\Uploads\<filename> ?
By default, Line 95 will simply take the full path of the file.
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
sure Lestat, here is the correct syntax for this:
Code:
Set objUpload=New ShadowUpload
If objUpload.FileCount>0 Then
Call objUpload.File(0).SaveToDisk(Server.MapPath("Uploads"), "")
End If
'changing all Request.Form to objUpload
If Trim(objUpload("Submit")) <> "" Then
Set myMail = CreateObject("CDO.Message")
myMail.Subject = Trim(objUpload("txtSubject"))
myMail.From = Trim(objUpload("txtEmail"))
myMail.To = "kevinloh@jobswalk.com"
myMail.TextBody = Trim(objUpload("txtCoverLetter"))
If objUpload.FileCount>0 Then
myMail.AddAttachment Server.MapPath("Uploads") & "\" & objUpload.File(0).FileName
End If
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 2
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "202.75.48.50"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 25
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 1
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "mail@jobswalk.com"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "abc123"
myMail.Configuration.Fields.Update
myMail.Send
Set myMail = nothing
End If
changes are marked in bold, I've also added code that will attach
only if any file has been uploaded, to avoid errors.
Posts: 5
Time spent in forums: 1 h 20 m 49 sec
Reputation Power: 0
Deleting Attachment after sending E-mail
Quote:
Originally Posted by Shadow Wizard
sure Lestat, here is the correct syntax for this:
Code:
Set objUpload=New ShadowUpload
If objUpload.FileCount>0 Then
Call objUpload.File(0).SaveToDisk(Server.MapPath("Uploads"), "")
End If
'changing all Request.Form to objUpload
If Trim(objUpload("Submit")) <> "" Then
Set myMail = CreateObject("CDO.Message")
myMail.Subject = Trim(objUpload("txtSubject"))
myMail.From = Trim(objUpload("txtEmail"))
myMail.To = "kevinloh@jobswalk.com"
myMail.TextBody = Trim(objUpload("txtCoverLetter"))
If objUpload.FileCount>0 Then
myMail.AddAttachment Server.MapPath("Uploads") & "\" & objUpload.File(0).FileName
End If
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 2
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "202.75.48.50"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 25
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 1
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "mail@jobswalk.com"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "abc123"
myMail.Configuration.Fields.Update
myMail.Send
Set myMail = nothing
End If
changes are marked in bold, I've also added code that will attach
only if any file has been uploaded, to avoid errors.
Dear Shadow Wizard,
Thank you so much for your assistance. Managed to get the script to finally work. Apparently after inputing the above code the same error still persist.
If objUpload.FileCount>0 Then
myMail.AddAttachment Server.MapPath("Uploads") & "\" & objUpload.File(0).FileName
End If
But after adding a TRIM() surrounding the Trim(objUpload.File(0).FileName), everything was fine. Apparently there were some spaces in the textfield eventhough I didn't leave any.
Lastly, once I got the e-mail sent out, how do I delete the attachment from my Uploads folder as I do not want to keep the uploads file after I have finished e-mailing to the appropriate party. Your kindly wisdom is needed here.
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
try deleting it right after you Send your email:
Code:
If objUpload.FileCount>0 Then
myMail.AddAttachment Server.MapPath("Uploads") & "\" & Trim(objUpload.File(0).FileName)
End If
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 2
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "202.75.48.50"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 25
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 1
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "mail@jobswalk.com"
myMail.Configuration.Fields.Item("(URL address blocked: See forum rules)") = "abc123"
myMail.Configuration.Fields.Update
myMail.Send
Set myMail = nothing
If objUpload.FileCount>0 Then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(Server.MapPath("Uploads") & "\" & Trim(objUpload.File(0).FileName))
Set objFSO = Nothing
End If
Posts: 232
Time spent in forums: 2 Days 11 h 51 m 24 sec
Reputation Power: 112
Hi!
I want to do the same thing,but my page is written in javascript.I try to include Shadowuploader in the page,but I don't think I'm doing it in the right way:
<%@ Language = JavaScript %>
<!-- #include file="ShadowUploader.asp" -->
<%
.
.
.
.
<script type="text/vbscript">
Dim objUpload
If Request("action")="1" Then
Set objUpload=New ShadowUpload
If objUpload.GetError<>"" Then
Response.Write("sorry, could not upload: "&objUpload.GetError)
.
.
.
.
</script>
Posts: 31,109
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
my code is ASP and can't be used with client side JavaScript.
learn the basics of ASP, good website to start is w3schools.com and
when you gain some basic skills try using the upload script without email.
when you have this working let me know and I can help you write the
code to email the uploaded file.