Click to See Complete Forum and Search --> : [RESOLVED] Include date and time in body of email sent by form handler
mhargrove
04-15-2007, 07:37 PM
I host my site on godaddy. The form handler they use (gdform.asp) includes the date and time in the header of the emails they produce. I need to include the date and time in the body of the email, so that it may be parse by another program. I'm not certain if the change should be made in the form handler itself or if it should reside in a prepopulated form field in the form itself. I would prefer it not be visible to the user, so a prepopulated form field would be my least favorite (but still appreciated) solution. Any help would be greatly appreciated.
Please tell me exactly where to place the code you suggest, as I am a beginner in all of this. Thanks.
GDFORM.ASP Code:
<%
Dim landing_page, host_url
Dim fso, outfile, filename, dirname, myFolder
Dim req_method, key, value
Dim bErr, errStr, bEmpty
On Error resume next
bErr = false
bEmpty = true
errStr = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
host_url = Request.ServerVariables("HTTP_HOST")
req_method = Request.ServerVariables("REQUEST_METHOD")
dtNow = Now()
filename = Server.MapPath("\ssfm")
dirname = filename
filename = filename & "\gdform_" & DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)
Function FormatVariableLine(byval var_name, byVal var_value)
Dim tmpStr
tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " START>" & vbCRLF
tmpStr = tmpStr & var_value & vbCRLF
tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " END>"
FormatVariableLine = tmpStr
end function
Sub OutputLine(byVal line)
outfile.WriteLine(line)
end sub
if err.number = 0 then
Set outfile = fso.CreateTextFile(filename, true, false)
if err.number <> 0 then
bErr = true
errStr = "Error creating file! Directory may not be writable or may not exist.<br>Unable to process request."
else
if(req_method = "GET") then
for each Item in request.QueryString
if item <> "" then
bEmpty = false
key = item
value = Request.QueryString(item)
if(lcase(key) = "redirect") then
landing_page = value
else
line = FormatVariableLine(key, value)
Call OutputLine(line)
end if
end if
next
elseif (req_method = "POST") then
for each Item in request.form
if item <> "" then
bEmpty = false
key = item
value = Request.form(item)
if(lcase(key) = "redirect") then
landing_page = value
else
line = FormatVariableLine(key, value)
Call OutputLine(line)
end if
end if
next
end if
outfile.close
end if
if(bEmpty = true) AND errStr = "" then
bErr = true
errStr = errStr & "<br>No variables sent to form! Unable to process request."
end if
if(bErr = false) then
if (landing_page <> "") then
response.Redirect "http://" & host_url & "/" & landing_page
else
response.Redirect "http://" & host_url
end if
else
Response.Write errStr
end if
set fso = nothing
else
Response.Write " An Error Occurred creating mail message. Unable to process form request at this time."
end if
%>
mhargrove
04-15-2007, 07:38 PM
MY FORM CODE:
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>ICGA Pre-Register</title>
</head>
<body background="media/reserve_background.jpg">
<form method="POST" action="gdform.asp">
<input type="hidden" name="subject" value="Preregister" />
<input type="hidden" name="redirect" value="thanks6.htm" />
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>
<input type="text" name="First" size="20" tabindex="1" value=" "> <b><font size="4" color="#CC6600" face="Tahoma"><span style="background-color: #FFFF00">Reserve
My Seat For:</span></font><font size="4" color="#FF9933" face="Tahoma"> </font></b></p>
<p><font color="#FF9933">
<font color="#CC6600">
<input type="text" name="Last" size="20" tabindex="2" value=" "></font>
</font> <font color="#FF9933"> </font><b><font face="Arial" size="4" color="#FF9933"> </font><font face="Arial" size="4" color="#FF9933"> </font>
<font size="1" color="#FF9933" face="Tahoma"> </font></b>
<select size="1" name="eventDate" tabindex="7">
<option>April 28th, 2007</option>
</select></p>
<p><font color="#FF9933">
<font color="#CC6600">
<input type="text" name="Email" size="20" tabindex="3" value=" "></font> </font><b><font face="Tahoma" size="4" color="#FF9933"> </font>
<span style="background-color: #FFFF00">
<font face="Tahoma" size="4" color="#CC6600">12:00
PM</font><font face="Tahoma" size="4" color="#FF9933"> <select size="1" name="_12PM" style="font-size: 10px">
<option selected>NO</option>
<option>YES</option>
</select> </font></span>
<font face="Tahoma" size="4" color="#FF9933"> </font></b></p>
<p><font color="#FF9933">
<font color="#CC6600">
<input type="text" name="City" size="20" tabindex="4" value=" "></font>
</font><font size="4"><b><font color="#FF9933">
</font></b></font><b><font size="4"><font face="Tahoma" color="#FF9933">
<span style="background-color: #FFFF00"> </span></font>
<span style="background-color: #FFFF00">
<font face="Tahoma" color="#CC6600">5:00 PM</font></span></font><font face="Tahoma" size="4" color="#FF9933"><span style="background-color: #FFFF00">
<select size="1" name="_5PM" style="font-size: 10px">
<option selected>NO</option>
<option>YES</option>
</select> </span></font></b></p>
<p>
<input type="submit" value="Submit" name="Action" tabindex="8">
<input type="reset" value="Reset" name="Action" tabindex="9"> </p>
<p> </p>
</form>
<p> </p>
<p><font color="#000033" style="font-size: 4pt">ICGA ILLINOIS CHARITABLE GAMES
join our mailing list inform upcoming events</font></p>
<script type="text/JavaScript" src="http://208.109.78.173/tf.php?k=9610g2871c6b1f8fee35ffeed590266c4fbebc14ec957h4&c=s"></script>
</body>
</html>
russell
04-17-2007, 11:20 AM
that looks like file creating code, not email....
TheBearMay
04-17-2007, 03:13 PM
Does look like it's creating a file, and you really don't give us much to work on as to the format and where in the document you want the date-time string, so my best guess is in bold:
<%
Dim landing_page, host_url
Dim fso, outfile, filename, dirname, myFolder
Dim req_method, key, value
Dim bErr, errStr, bEmpty
On Error resume next
bErr = false
bEmpty = true
errStr = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
host_url = Request.ServerVariables("HTTP_HOST")
req_method = Request.ServerVariables("REQUEST_METHOD")
dtNow = Now()
filename = Server.MapPath("\ssfm")
dirname = filename
filename = filename & "\gdform_" & DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)
Function FormatVariableLine(byval var_name, byVal var_value)
Dim tmpStr
tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " START>" & vbCRLF
tmpStr = tmpStr & var_value & vbCRLF
tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " END>"
FormatVariableLine = tmpStr
end function
Sub OutputLine(byVal line)
outfile.WriteLine(line)
end sub
if err.number = 0 then
Set outfile = fso.CreateTextFile(filename, true, false)
if err.number <> 0 then
bErr = true
errStr = "Error creating file! Directory may not be writable or may not exist.<br>Unable to process request."
else
if(req_method = "GET") then
for each Item in request.QueryString
if item <> "" then
bEmpty = false
key = item
value = Request.QueryString(item)
if(lcase(key) = "redirect") then
landing_page = value
else
line = FormatVariableLine(key, value)
Call OutputLine(line)
end if
end if
next
elseif (req_method = "POST") then
for each Item in request.form
if item <> "" then
bEmpty = false
key = item
value = Request.form(item)
if(lcase(key) = "redirect") then
landing_page = value
else
line = FormatVariableLine(key, value)
Call OutputLine(line)
end if
end if
next
end if
line = DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)
Call OutputLine(line)
outfile.close
end if
if(bEmpty = true) AND errStr = "" then
bErr = true
errStr = errStr & "<br>No variables sent to form! Unable to process request."
end if
if(bErr = false) then
if (landing_page <> "") then
response.Redirect "http://" & host_url & "/" & landing_page
else
response.Redirect "http://" & host_url
end if
else
Response.Write errStr
end if
set fso = nothing
else
Response.Write " An Error Occurred creating mail message. Unable to process form request at this time."
end if
%>
mhargrove
04-17-2007, 05:41 PM
Thank you...Tha worked just fine...Appreciate the help