Using the CSV file is by far the easiest.
Just before the Response.Redirect line at the end, add this code:
Code:
CONST QT = """" ' creates a single quote mark
' put the items into the array in whatever order you prefer:
csvItems = Array( UserIPAddress, strFeedTitle, strFeedName, strFeedEmail, _
strFeedCell, strFeedCompany, strFeedSubject, strFeedMessage )
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set csv = FSO.OpenTextFile( Server.MapPath("emailLog.csv"), 8, True )
csv.WriteLine QT & Join( csvItems, QT & "," & QT ) & QT
csv.Close
Set FSO = Nothing
response.redirect("../thankyou.html")
%>
The only thing to watch out for is here:
Code:
Server.MapPath("emailLog.csv")
Aside from the fact that you can use any file name of your choice, though it should end in ".csv", that code as written probably won't work. That says "find the CSV text file in the same directory as this code." Almost surely the directory with the code will *NOT* be writable.
Typically, you will have a writable "data" directory that is either a subdirectory of the code directory or is "besided" the code subdirectory. So you will likely need something such as
Code:
Server.MapPath("data/emailLog.csv")
or
Server.MapPath("/data/emailLog.csv")
or
Server.MapPath("../data/emailLog.csv")
You will have to figure that part out based on the directory structure on your machine.
This code should write out a CSV file that looks like
Code:
"68.128.3.7","Amalgamated Widgets","Today's Widget Report","...", etc.
TWO CAUTIONS: In a ".csv" file like this, *NONE* of the field may contain *EITHER* quote marks or new line characters.
If you are unsure if they might, you could use a "cleaner" function something like:
Code:
Function clean( txt )
clean = Replace( Replace( Replace( txt, """","'" ), vbCR, " ", vbLF, " " )
End Function
And then construct the array using that function:
Code:
csvItems = Array( UserIPAddress, clean(strFeedTitle), clean(strFeedName), _
clean(strFeedEmail), clean(strFeedCell), clean(strFeedCompany), _
clean(strFeedSubject), clean(strFeedMessage) )
Give it a shot!