|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
(regarding this thread)
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 07:25 AM. |
|
#2
|
||||
|
||||
|
copy the function SendEmail from here:
http://forums.aspfree.com/code-bank...nent-49734.html having this function, add such line to the upload code: Code:
strFileName = "new_file"
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), strFileName)
SendEmail("someone@something.com", "your@email.com", "sending file", "hello how are you?", Array(Server.MapPath("Uploads/" & strFileName)))
this will save the file and email it using CDO component. |
|
#3
|
|||
|
|||
|
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 07:14 AM. Reason: added [Code] and [/Code] tags around code - please do that yourself next! |
|
#4
|
||||
|
||||
|
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: http://forums.aspfree.com/asp-devel...uide-96087.html (just give the permissions to the whole folder instead of single MDB file) |
|
#5
|
|||
|
|||
|
Quote:
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 : EmailSent.asp [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 %> <% '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. ----------------------------------------------------------- Please try the following: 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. |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||
|
|||
|
Quote:
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? |
|
#8
|
||||
|
||||
|
in your code, you're missing this line:
Code:
Set objUpload=New ShadowUpload you must add this line before trying to read the files. |
|
#9
|
|||
|
|||
|
Quote:
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. Your help is most appreciated. Thank you. Lestat |
|
#10
|
||||
|
||||
|
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. |
|
#11
|
|||
|
|||
|
Quote:
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. Thanks a million. Lestat |
|
#12
|
||||
|
||||
|
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
|
|
#13
|
||||
|
||||
|
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> |
|
#14
|
||||
|
||||
|
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. |
|
#15
|
||||
|
||||
|
I figured out another way to use your upload script....but anyway,thanks...
|
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Shadow Uploader - Email the uploaded file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|