This is a discussion on "More script problems yet again" within the Classic ASP section. This forum, and the thread "More script problems yet again are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
More script problems yet again
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
This is the script (it submits form values to an email address):
<%@ Language=VBScript %> <html> <head> </head> <body> <% Dim iMsg Set iMsg = CreateObject("CDO.Message") Dim iConf Set iConf = CreateObject("CDO.Configuration") Dim Flds Set Flds = iConf.Fields Flds( "http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup" '<-----xxx this path needs to point to the right place on the server. The hosts will know what it should say. Most probably, it will stay the same. Flds.Update Set iMsg.Configuration = iConf iMsg.To = "email address" ' iMsg.From = Request.Form.Item("email") iMsg.Subject = "form submission" iMsg.TextBody = "TradeName: " & Request.Form.Item("TradeName") & vbCrLf & "Address: " & Request.Form.Item("Address") & vbCrLf & "Post Code: " & Request.Form.Item("PostCode") & vbCrLf & "Contact Name: " & Request.Form.Item("ContactName") & vbCrLf & "Email: " & Request.Form.Item("Email") & vbCrLf & "Web Address: " & Request.Form.Item("WebAddress") & vbCrLf & "Holidays: " & Request.Form.Item("Holidays") & vbCrLf & "InnsPubs: " & Request.Form.Item("InnsPubs") & vbCrLf & "Leisure: " & Request.Form.Item("Leisure") & vbCrLf & "Hobbies: " & Request.Form.Item("Hobbies") & vbCrLf & "ComputersICT: " & Request.Form.Item("ComputersICT") & vbCrLf & "ConsumerElec: " & Request.Form.Item("ConsumerElec") & vbCrLf & "BankingFinance: " & Request.Form.Item("BankingFinance") & vbCrLf & "LandEstate: " & Request.Form.Item("LandEstate") & vbCrLf & "HomeHousehold: " & Request.Form.Item("HomeHousehold") & vbCrLf & "ShopsStores: " & Request.Form.Item("ShopsStores") iMsg.AddAttachment Request.Form.Item("file"), Request.Form.Item("file") iMsg.Send %> <a href="http://www.....">Back to home page</a> </body> </html> The Problem: If I enter values into the form fields everything works OK (it gets sent to the email address with no problem), except if I try to send a file attachment via the file field - hence; ' iMsg.AddAttachment Request.Form.Item("file"), Request.Form.Item("file") '. Basically I get an error message saying 'protocol not accepted', and I'm just wondering if anyone know why this is? Again, this only happens in trying to send an attachment, which is the main reason for having the script at all. |
|
|
|
#2
|
|||
|
|||
|
Re: More script problems yet again
You have to upload the file first then attach it. Also to upload the file you need to have the form element have this in it:
enctype="multipart/form-data" |
|
#3
|
|||
|
|||
|
Re: More script problems yet again
I use www.aspupload.com
|
|
#4
|
|||
|
|||
|
Re: More script problems yet again
Many thanks.
I don't understand however. The clause ' enctype="multipart/form-data" ' is what Dreamweaver (the editor that I use) puts into html documents that contain a form if a 'form action' is not specified. However, the person that did this ASP script for me did not include, or left out 'enctype="multipart/form-data" ' in the html document, his reasoning being that this was usual once a form action had been given, e.g; filename.asp. In any case, he sent me the results of an initial test after he had completed the script, and it was OK; that is, an image (via the file-field) was included in the body of the email, that is, not as an attachment - which is exactly what I wanted the script to do. But for some reason, which is why I submitted this post, it isn't working for me(?) What exactly do you mean by 'upload the file'? The attachment is to go to an email address, and not online. No offense, but this is confusing... Obviously the ASP will reside at some point on the host's server , along with the htm form page and all other htm pages, but at the moment, because it is all still offline, I am of course using IIS, and any file submitted via the form's file-field resides on my local machine - where else? But as your ASP knowledge is no doubt greater than mine, could you possibly just tel me in a literal sense, how I have to change (if at all) the script that I've shown? Last edited by a.jenery; Apr 26th, 2006 at 09:54. |
|
#5
|
||||
|
||||
|
Re: More script problems yet again
Let me me explain what happens to ANY web page when a file input is used.
First of all, the form is submitted and the data is sent to the server. The file you select is UPLOADED to the web server (even if that is the same machine - your local machine) The .asp script that processes the information uploaded can ONLY process it if the enctype="multipart/form-data" parameter is added to the HTML form declaration. If the image or whatever other file uploaded is 'emailed' to you, then that will be the work of the .asp script.... it does NOT happen automatically. If you are not receiving the email, then this will likely be because the script is using CDONTS or CDOSYS to send the email and your SMTP service on your local IIS installation is not properly set up (localhost set up of smtp with IIS is notoriously a pain in the neck to get going) My guess, is that you have emails sitting on your machine in the SUB FOLDERS of the following folder:- c:\inetpub\mailroot Check out all sub-folders there.... you prolly have queued emails, or bad emails in the respective folders. (I'm not sure anything is actually wrong with your script) Hope this helps and hope I have correctly understood your problem.
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
Last edited by Rob; Apr 26th, 2006 at 13:01. |
|
#6
|
|||
|
|||
|
Many thanks...
Quote: The .asp script that processes the information uploaded can ONLY process it if the enctype="multipart/form-data" parameter is added to the HTML form declaration. Un-quote. As I tried to explain initially, enctype="multipart/form-data" was originally in the HTML form that I emailed to the person who did the ASP for me, and is what Dreamweaver generates automatically/by default if a form-action is not given. But, when he returned the HTML form to me, together with the ASP script, enctype="multipart/form-data" was no longer in the HTML. Natrurally, I pointed this out to him, but he said that it was not required. What ever, I shall now add the enctype="multipart/form-data" and see if it works. OK - I added this to the form declaration, but I got the error mesage: Error Type: CDO.Message.1 (0x8004020D) At least one of the From or Sender fields is required, and neither was found. /MyWeb/SscapeForm2email.asp, line 23 Quote: If the image or whatever other file uploaded is 'emailed' to you, then that will be the work of the .asp script.... it does NOT happen automatically. Unquote. I know this, and I never implied otherwise. Of course it is the work of the ASP script (no offense...). Quote: If you are not receiving the email, then this will likely be because the script is using CDONTS or CDOSYS to send the email and your SMTP service on your local IIS installation is not properly set up (localhost set up of smtp with IIS is notoriously a pain in the neck to get going) Un-quote. I am recieving emails via the ASP script! It only get the error message that I mentioned, if I attempt to send a file-field. The script works fine with all other form-field values submitted, but not with file-fields which is the whole point of the script! Quote: My guess, is that you have emails sitting on your machine in the SUB FOLDERS of the following folder:- c:\inetpub\mailroot Check out all sub-folders there.... you probably have queued emails, or bad emails in the respective folders. Unquote. I'll check this out - but why would IIS via the script send the emails to my local machine? Why do you even mention this? I don't understand... Last edited by a.jenery; Apr 28th, 2006 at 10:42. |
|
#7
|
||||
|
||||
|
Re: More script problems yet again
I thought you were running this on your local machine's IIS.
Please post your the entire form HANDLER code. I think this would be SscapeForm2email.asp Also post any dependant include files. Thanks
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#8
|
||||
|
||||
|
Re: More script problems yet again
Actually, I see the error. You are NOT using an upload component when in fact you NEED one to retrieve the submitted fields AND the file.
Please upload a zip of the HTML page AND the FORM HANDLER. I can fix this for you and get it going OK.
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#9
|
|||
|
|||
|
Re: More script problems yet again
Many thanks for your offer.
I am running the ASP on my machine's IIS (I'm starting to lose the plot here...). Mmmm - just to make certain of what you want me to do, you want the ASP script which is 'SscapeForm2email.asp' (this is the script shown in my initial thread/post), and the html form-page sent in a ZIP file? Also, I've no idea what is an upload componant in this context. Is this similar to an FTP program, or? I don't know if I have any dependant include files either. Where would I look for these. All I have is the ASP and HTML docs. |
|
#10
|
||||
|
||||
|
Re: More script problems yet again
Just post a zip of the htm file and it's .asp handler.
Use full reply mode in this thread, and look below the message area for a 'manage attachments button. ie... dont use quick reply.
__________________
Click the 'Thanks!' button if this post has helped you Rob - Webforumz Founder
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
#11
|
|||
|
|||
|
Re: More script problems yet again
This will sound completely crazy, only I've forgotten how you zip a file, even though I've done this many times. An added problem is that I can't find my zip program - I know it's in Win-XP Pro' somewhere...
Last edited by a.jenery; May 3rd, 2006 at 11:58. |
|
#12
|
|||
|
|||
|
Re: More script problems yet again
....but then I suddenly remembered that of course you right-click on 'Send To'.
Anyway, here are the zipped HTM and ASP files: SscapeForm2email.zip (the ASP handler) and SscapeForm.zip (the HTM form). The HTM is exactly how I initially submitted it to the person who did the script for me, and the ASP is exactly the one that he emailed to me after doing the initial test, which for him worked (somehow...); that is, he was able to submit an attachment via the file-field as well as other form-field values. |
|
#13
|
|||
|
|||
|
Re: More script problems yet again
OK - I've posted ZIP's of the files asked for, what next?
|
![]() |
| Tags |
| script, problems, yet, again |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Database Update script problems | as22607 | PHP Forum | 10 | May 14th, 2007 18:08 |
| Login Script problems | as22607 | PHP Forum | 8 | May 10th, 2007 21:42 |
| asp file upload script having problems with MYSQL | paulmcn | Classic ASP | 2 | Oct 5th, 2005 18:45 |
| Slideshow script problems | autumn_whispers2me | JavaScript Forum | 4 | Dec 7th, 2004 17:14 |