ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 21st, 2003, 10:19 AM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 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, 12:28 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
use OpenTextFile instead

Since you did not mention which error occurred, I just looked at the script and picked on the following:

1. You are better off using the OpenTextFile method:
Code:
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 

The true in the openTextFile (the create argument) ensures that the file will be created the first time the log gets written to.

Here more information about this filesystemobject method:
http://www.devguru.com/Technologies...entextfile.html

2. Ensure the submit folder has write permissions for the web user (IUSR_[computer name]). That is also a frequent error.

Hope this helps.
__________________
- Rogier Doekes

Reply With Quote
  #3  
Old October 21st, 2003, 01:32 PM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The error that it gives is as follows...

execution error
description = expected end of statement
line number = unknown
error number = 1025
page name = txwc-result_contact.dat
object coordinates = 1:3
1:3
1:3
1:3
1:3



And that happens even with what you had informed me to change, unfortunately, so I am still having the error.

Reply With Quote
  #4  
Old October 21st, 2003, 01:44 PM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 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
  #5  
Old October 21st, 2003, 01:54 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
I think you need to define some variables

Dim a, fs, folderPath

Reply With Quote
  #6  
Old October 21st, 2003, 02:04 PM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Doh, thanks, it all works now with one exception...

How do I make it so that it doesn't overwrite the file each time? So that it just appends the info to it?

Reply With Quote
  #7  
Old October 21st, 2003, 02:08 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 16
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
iso Const ForWriting = 2
Code:
Const ForAppending = 8
...
Set a = fs.OpenTextFile(folderpath & "\submitlog.txt", ForAppending, True)

Reply With Quote
  #8  
Old October 21st, 2003, 02:59 PM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 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
  #9  
Old October 21st, 2003, 04:33 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 16
Quote:
And, so that this exercise in my ineptitude with ASP may possibly benefit anyone...
Do not down yourself for not knowing. If you keep asking questions you will soon find that all the little pieces that don't really make sense now will make sense soon. You may find that you have to piece together scripts to make a working application... that is ok as long as you are constantly developing an apptitude for understanding the concept behind each script. As long as you take some knowledge away from each small project you work on, you will do just fine.

Take Care.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #10  
Old October 21st, 2003, 04:41 PM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Oh, I wasn't meaning to down myself, I was just being factually honest. I really don't have any ego one way or the other.

But as far as my capabilities go... I actually try quite hard normally not to be a developer, I profess to be a technical writer, but with how hard it is to find that work in Houston, I took a position with a law firm as a web developer. I told them up front that I'm not, but I seem to find ways to do things well enough to make them happy, and faster than quite a few serious developers they've had... so oh well. I just keep trying to make them happy. <smiles>

I just also have this thing about me wherein I like to help others, so I figured that hey, if my ineptitude can teach you something, then there you go. <smiles>

Reply With Quote
  #11  
Old October 21st, 2003, 04:52 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 16
LOL... thats a pretty cool attitude. So, how does it feel to actually kick some "serious developer" butt? You've got to admit it does do a little bit for the ego now...

Reply With Quote
  #12  
Old October 21st, 2003, 04:58 PM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You know, I've never looked at it like that. I mean, the only reason I can think of is because of two different things...

1) I refuse to do it fast, I will do it right the first time. And by that I just mean that I have an absolutely anal adherance to standards. If I am doing it like this, then I will force the entire rest of the site to have it done like that, use styles for everything (learned that from technical writing), and just enforce the standards religiously, that way you never have to wonder "so how was this page coded this time?" Heck, if I find a better way of doing it, I almost immediately go back and redo all the others to fit it.

2) I ask for help. And this is what I think helps me most, most seasoned developers seem to think they know it, and spend forever looking through books trying to figure out how to do it. If I can't figure it out in about an hour, I'll typically post and ask all you wonderful people out there how. I mean there's enough brains out there in the ether that why would I sit there and trust my meager measure to figure it out and waste time and my employer's money? <shrugs>

So really I don't think I am kicking serious developer butt... I just know how to "stop and ask for directions" when I need to. <smiles>

Reply With Quote
  #13  
Old October 21st, 2003, 05:34 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 16
If more developers thought like that you know we would have much better software?

Reply With Quote
  #14  
Old October 22nd, 2003, 08:25 AM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 NoahC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
LOLOL, possibly, but you never know... if more developers thought like that, then chances are more people with nefarious motives may think to give them bad advice, just for fun. <smiles> And again, I'm not a developer. <snickers> So as far as I know, there aren't any developers that think like that. That's why they're developers...

Reply With Quote
  #15  
Old October 23rd, 2003, 10:29 AM
NoahC NoahC is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 9 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 Articles Community ForumsProgrammingASP Development > Anyone able to help me with a saving to file script?


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap