|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Anyone able to help me with a saving to file script?
OK... first off here is the script:
Dim TodaysDate Dim Body Dim FromEmail Dim HomePhone Dim OptionalInfo Dim FirstName Dim LastName Dim objNewMail 'Request the form elements from the last page FromEmail = request.form("Email") OptionalInfo = request.form("Optional") FirstName = request.form("FirstName") HomePhone = request.form("HomePhone") LastName = request.form("LastName") TodaysDate=now() Body = FirstName & vbCrLf Body = Body & LastName & vbCrLf & vbCrLf Body = Body & TodaysDate & vbCrLf Body = Body & HomePhone & vbCrLf Body = Body & OptionalInfo & vbCrLf Body = Body & FromEmail & vbCrLf Body = Body & Texas Workers Comp.net & vbCrLf & vbCrLf & vbCrLf & vbCrLf Set fs = CreateObject("Scripting.FileSystemObject") Folderpath=server.mappath("\") & "/submit" Set a = fs.CreateTextFile(Folderpath & "\submitlog.txt") a.WriteLine(Body) a.Close Set a=nothing Set fs=nothing simpleemail "edited@tonotshow.addy","edited@tonotshow.addy",FromEmail,FromEmail,"","","editedtonotshow.domain",Body,"","" Now, for some time this script has been used to send an e-mail to us every time someone fills out a form with the contents of the form. But now my boss wants that script to save the contents of the form to a file, as well as send out the e-mail, which is why these lines were added: Set fs = CreateObject("Scripting.FileSystemObject") Folderpath=server.mappath("\") & "/submit" Set a = fs.CreateTextFile(Folderpath & "\submitlog.txt") a.WriteLine(Body) a.Close Set a=nothing Set fs=nothing Without those lines, there are no errors on the page, but with those lines there most certainly are... so... any thoughts? I created a submit folder right off of the root, and put a file called "submitlog.txt" inside of it. But when I try to run the script I get an execution error. Any thoughts? |
|
#2
|
|||
|
|||
|
What error?
|
|
#3
|
|||
|
|||
|
OK... I have changed the code to read as follows...
Dim TodaysDate Dim Body Dim FromEmail Dim HomePhone Dim OptionalInfo Dim FirstName Dim LastName Dim objNewMail 'Request the form elements from the last page FromEmail = request.form("Email") OptionalInfo = request.form("Optional") FirstName = request.form("FirstName") HomePhone = request.form("HomePhone") LastName = request.form("LastName") TodaysDate = now() Body = FirstName & vbCrLf Body = Body & LastName & vbCrLf Body = Body & vbCrLf Body = Body & TodaysDate & vbCrLf Body = Body & HomePhone & vbCrLf Body = Body & OptionalInfo & vbCrLf Body = Body & FromEmail & vbCrLf Body = Body & "edited to remove email domain" & vbCrLf & vbCrLf & vbCrLf & vbCrLf Const ForWriting = 2 Set fs = Server.CreateObject("Scripting.FileSystemObject") Folderpath= server.mappath("\") & "\submit" Set a = fs.OpenTextFile(Folderpath & "\submitlog.txt", ForWriting, True) a.WriteLine(Body) a.Close Set a=nothing Set fs=nothing simpleemail "edited to remove email addy","edited to remove email addy",FromEmail,FromEmail,"","","edited to remove email domain",Body,"","" And now this is the error that I am getting. execution error description = variable is undefined line number = 34 error number = 500 page name = txwc-result_contact.dat object coordinates = 1:3 1:3 1:3 1:3 1:3 |
|
#4
|
|||
|
|||
|
Doh... it all works now, the file is written to. Now the only question is...
How do I make it so that it just appends to the file, and not overwrite it each time? |
|
#5
|
|||
|
|||
|
I want to thank everyone that helped me on the different boards I've been posting on, you have all been an excellent help. And, so that this exercise in my ineptitude with ASP may possibly benefit anyone else who ever wants to do what I have been working on here, here is the code that eventually worked and worked well. Note that the e-mail functionality is using a function that I think is for our site only, the simpleemail function, but otherwise it may prove helpful.
Dim TodaysDate Dim Body Dim FromEmail Dim HomePhone Dim OptionalInfo Dim FirstName Dim LastName Dim objNewMail Dim fs Dim a Dim Folderpath Dim SubTxt 'Request the form elements from the last page FromEmail = request.form("Email") OptionalInfo = request.form("Optional") FirstName = request.form("FirstName") HomePhone = request.form("HomePhone") LastName = request.form("LastName") TodaysDate = now() SubTxt = FirstName & "^" & LastName & "^" & TodaysDate & "^" & HomePhone & "^" & OptionalInfo & "^" & FromEmail & "^" & "Texas Workers Comp.net" Body = FirstName & vbCrLf Body = Body & LastName & vbCrLf Body = Body & vbCrLf Body = Body & TodaysDate & vbCrLf Body = Body & HomePhone & vbCrLf Body = Body & OptionalInfo & vbCrLf Body = Body & FromEmail & vbCrLf Body = Body & "edited to remove email domain" Const ForAppending = 8 Set fs = Server.CreateObject("Scripting.FileSystemObject") Folderpath= server.mappath("\") & "\submit" Set a = fs.OpenTextFile(Folderpath & "\submitlog.txt", ForAppending, True) a.WriteLine(SubTxt) a.Close Set a=nothing Set fs=nothing simpleemail "edited to remove email addy","edited to remove email addy",FromEmail,FromEmail,"","","edited to remove email domain",Body,"","" |
|
#6
|
|||
|
|||
|
OK... I had thought that this was done, but then I decided to make one minor change...
The server I am working on hosts multiple domains, since all the domains are ours, I decided that I wanted this to work for all the e-mail forms (OK, my boss did, but it was a good idea). Anyway... as a result I figured that I would make the submit directory, off the root of the domain, would be a virtual directory... but the moment I do, and remove the actual directory (the virtual directory is there, and the file is in it, and IIS shows it as if it is all good). execution error description = object required line number = 41 error number = 424 page name = ogl-result_askaquestion.dat object coordinates = 1:1 1:1 1:1 Here is the code as I have it now: Dim TodaysDate Dim fs Dim a Dim Folderpath Dim SubTxt Dim Body Dim FromEmail Dim HomePhone Dim Subject Dim OptionalInfo Dim FirstName Dim LastName Dim objNewMail 'Request the form elements from the last page FromEmail = request.form("Email") OptionalInfo = request.form("Optional") FirstName = request.form("FirstName") HomePhone = request.form("HomePhone") Subject = request.form("QuestionType") LastName = request.form("LastName") TodaysDate = now() SubTxt = FirstName & "^" & LastName & "^" & TodaysDate & "^" & HomePhone & "^" & FromEmail & "^" & Subject & "^" & OptionalInfo & "^" & "Texas Workers Comp.net" Body = FirstName & vbCrLf Body = Body & LastName & vbCrLf Body = Body & vbCrLf Body = Body & TodaysDate & vbCrLf Body = Body & HomePhone & vbCrLf Body = Body & FromEmail & vbCrLf Body = Body & Subject & vbCrLf Body = Body & OptionalInfo & vbCrLf Body = Body & "censored domain" Const ForAppending = 8 Set fs = Server.CreateObject("Scripting.FileSystemObject") Folderpath= server.mappath("\") & "\submit" Set a = fs.OpenTextFile(Folderpath & "\submitlog.txt", ForAppending, True) a.WriteLine(SubTxt) a.Close Set a=nothing Set fs=nothing simpleemail "censored email addy","censored email addy",FromEmail,FromEmail,"","",Subject,Body,"","" If you have any idea how I can make it work with the virtual directory, I would much appreciate that. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Anyone able to help me with a saving to file script? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|