form results- both emailed and written to file

Results 1 to 2 of 2

Thread: form results- both emailed and written to file

  1. #1
    Join Date
    Dec 1969

    Default form results- both emailed and written to file

    Someone responded to this on Sat. But my thread dissappeared before I could copy the code. Emailed responses are working fine when the address is in there, but my txt file remains empty. Something about the server map path in the fso code. <BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;% Option Explicit %&#062;<BR>&#060;%<BR> <BR><BR>&#039;The header/footer for the email.<BR> Const strHeader = "Here are the results of the form:"<BR> Const strFooter = ""<BR><BR> &#039;Who does this go to?<BR> Const strTo = ""<BR> <BR> &#039;This information is optional<BR> Dim strFrom, strSubject, strRedirectURL, strFromPath<BR> <BR> strFrom = Request.Form("txtSendToEmailAddress")<BR> if Len(strFrom) = 0 then strFrom = strTo<BR> <BR> strSubject = Request.Form("txtEmailSubject")<BR> if Len(strSubject) = 0 then strSubject = "Survey Results"<BR> <BR> strRedirectURL = Request.Form("urlSendTo")<BR> if Len(strRedirectURL) = 0 then strRedirectURL = "index.asp"<BR> <BR> strFromPath = Request.Form("urlFromPath")<BR> if Len(strFromPath) = 0 then strFromPath = "How did you hear about ?"<BR> <BR> <BR><BR> Dim strBody<BR> strBody = strBody & "FORM: " & strFromPath & vbCrLf & _<BR> "FORM submitted at " & Now() & vbCrLf & vbCrLf<BR><BR> Dim myElement <BR> For Each myElement in Request.Form<BR> Select Case Left(myElement,3)<BR> Case "txt","sel","rad":<BR> strBody = strBody & Replace(Mid(myElement,4,len(myElement)),"."," ") & _<BR> ": "<BR> if Len(Request.Form(myElement)) = 0 then<BR> strBody = strBody & "UNANSWERED"<BR> else<BR> strBody = strBody & Request.Form(myElement)<BR> end if<BR> <BR> strBody = strBody & vbCrLf<BR> <BR> Case "chk":<BR> strBody = strBody & Replace(Mid(myElement,4,len(myElement)),"."," ") & _<BR> ": " & Request.Form(myElement) & vbCrLf<BR> End Select <BR> Next<BR> <BR> strBody = strBody <BR> <BR> <BR><BR> &#039;Time to send the email<BR> Dim objCDO<BR> Set objCDO = Server.CreateObject("CDONTS.NewMail")<BR> objCDO.To = strTo<BR> objCDO.From = strFrom<BR> <BR> objCDO.Subject = strSubject<BR> objCDO.Body = strBody<BR> <BR> objCDO.Send<BR> Set objCDO = Nothing<BR> <BR> Response.Redirect strRedirectURL<BR> &#039; create the fso object<BR> <BR> Set fso = Server.CreateObject("Scripting.FileSystemObject")< BR> <BR> path = "results.txt"<BR> <BR> &#039;ForReading = 1, ForWriting = 2, ForAppending = 3<BR> <BR> <BR> <BR> &#039; open the file<BR> <BR> set file = fso.opentextfile(path, ForAppending, TRUE)<BR> <BR> &#039; write the info to the file<BR> <BR> file.write(strBody) & vbcrlf<BR> <BR> &#039; close and clean up<BR> <BR> file.close<BR> <BR> set file = nothing<BR> <BR> set fso = nothing<BR>%&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default To find an older thread/message...

    Look for the hyperlink that says "See posts from ...." on the main page (that is, the list of all "current" messages).<BR><BR>If you post to an older thread, it is automatically moved into the list of current messages! The *newest* posting date is what determines when a message will be moved to older pages.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts