ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 21st, 2003, 10:40 AM
NoahC NoahC is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 5 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old October 21st, 2003, 01:46 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,790 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 14 h 29 m 54 sec
Reputation Power: 746
What error?

Reply With Quote
  #3  
Old October 21st, 2003, 01:47 PM
NoahC NoahC is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 5 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old October 21st, 2003, 02:09 PM
NoahC NoahC is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 5 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #5  
Old October 21st, 2003, 03:01 PM
NoahC NoahC is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 5 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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,"",""

Reply With Quote
  #6  
Old October 23rd, 2003, 10:33 AM
NoahC NoahC is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 5 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Anyone able to help me with a saving to file script?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway