我有一個經典的ASP頁面,列出了數據庫中的一些屬性,每個屬性都有一個小的聯繫表單 - 使用戶能夠從屬性代理中「請求回調」屬性。發送帶記錄集數據的電子郵件
但是,無論我完成哪種表單 - 發送給代理的電子郵件始終包含頁面上第一個屬性的詳細信息,而不是該用戶請求回撥的屬性。
這是我在列表頁面上的代碼(以及聯繫表格);
<%
Dim rspropertyresults
Dim rspropertyresults_numRows
Set rspropertyresults = Server.CreateObject("ADODB.Recordset")
rspropertyresults.ActiveConnection = MM_dbconn_STRING
rspropertyresults.Source = "SELECT * FROM VWTenantPropertiesResults ORDER BY ContentID DESC"
rspropertyresults.CursorType = 0
rspropertyresults.CursorLocation = 2
rspropertyresults.LockType = 1
rspropertyresults.Open()
rspropertyresults_numRows = 0
%>
<%
sys_message = ""
If (Request.Form("form_submit") <> "") Then
Response.Write("<h1>Form Submitted</h1>")
%><!--#include file="docallback.asp"--><%
End If %>
<body id="propertyresults">
<% If Not rspropertyresults.EOF Or Not rspropertyresults.BOF Then %>
<%
While ((RepeatProperties__numRows <> 0) AND (NOT rspropertyresults.EOF))
%>
<div class="propertydetails">
<ul>
<li class="price"><% If (rspropertyresults("ContentPrice")) <> "" Then %><%= FormatCurrency((rspropertyresults.Fields.Item("ContentPrice").Value), 2, -2, -2, -2) %> PCM<% End If ' price true %></li>
<li class="address"><%=varFullAddress%></li>
<% If (rspropertyresults.Fields.Item("ContentDetails").Value) <> "" AND (rspropertyresults.Fields.Item("ContentDetails").Value) <> "<p><br /></p>" Then %><li><%=StripHTML(rspropertyresults.Fields.Item("ContentDetails").Value)%></li><% End If ' details true %>
</ul>
</div>
<div class="propertyimage">
<a class="badge-callback" id="badge-callback<%=(rspropertyresults.Fields.Item("ContentID").Value)%>" title="Request Callback" href="#">Request Callback</a>
<div id="panel<%=(rspropertyresults.Fields.Item("ContentID").Value)%>">
<form action="default.asp" name="frmCallback" id="form_callback" method="post">
<fieldset>
<legend><h2>Request a callback</h2></legend>
<dl>
<dt><label id="name">Name</label></dt>
<dd><input id="form_input" type="text" name="txtName" /></dd>
<dt><label id="email_address">Email</label></dt>
<dd><input id="form_input" type="text" name="txtEmail" /></dd>
<dt><label id="telephone">Telephone</label></dt>
<dd><input id="form_input" type="text" name="txtTelephone" /></dd>
<input type="hidden" name="form_submit" value="submitted" />
<dt><input type="submit" value="Request a callback"></dt>
</dl>
</fieldset>
</form>
</div>
</div>
<%
RepeatProperties__index=RepeatProperties__index+1
RepeatProperties__numRows=RepeatProperties__numRows-1
rspropertyresults.MoveNext()
Wend
%>
我也有一個docallback.asp頁面處理電子郵件發送;
<%
fldName = replace(request.Form("fldName"),"'","")
fldTelephone = replace(request.Form("fldTelephone"),"'","")
fldEmail = replace(request.Form("fldEmail"),"'","")
mBody = "<html><style>body,p,td{font-family:arial;font-size:12px;}</style><body>"
mBody = mBody & "<p>A tenant has requested a call back for further information regarding the following property:</p>"
If (rspropertyresults.Fields.Item("ContentHouseNo").Value) <> "" Then
varFullAddress = (rspropertyresults.Fields.Item("ContentHouseNo").Value) & " "
End If
varFullAddress = varFullAddress & (rspropertyresults.Fields.Item("ContentStreet").Value)
If (rspropertyresults.Fields.Item("ContentStreet2").Value) <> "" Then
varFullAddress = varFullAddress & " " & (rspropertyresults.Fields.Item("ContentStreet2").Value)
End If
If (rspropertyresults.Fields.Item("ContentTown").Value) <> "" Then
varFullAddress = varFullAddress & " " & (rspropertyresults.Fields.Item("ContentTown").Value)
End If
If (rspropertyresults.Fields.Item("ContentArea").Value) <> "" Then
varFullAddress = varFullAddress & " " & (rspropertyresults.Fields.Item("ContentArea").Value)
End If
varFullAddress = varFullAddress & " " & (rspropertyresults.Fields.Item("ContentPostCode").Value)
mBody = mBody & "<p>" & varFullAddress & "</p>"
mBody = mBody & "<p>Their details are:</p>"
If request.Form("fldName") <> "" Then
mBody = mBody & "<p>Name: " & request.Form("fldName") & "<br/>"
End If
If request.Form("fldTelephone") <> "" Then
mBody = mBody & "Telephone: " & request.Form("fldTelephone") & "<br/>"
End If
If request.Form("fldEmail") <> "" Then
mBody = mBody & "Email: " & request.Form("fldEmail") & "</p>"
End If
mBody = mBody & "<p>" & "<strong>" & "http://www."& varSiteDomain & "</strong>" & "</p>"
mBody = mBody & "</body></html>"
strMSSchema = "http://schemas.microsoft.com/cdo/configuration/"
Set oCdoConfg = Server.CreateObject("CDO.Configuration")
oCdoConfg.Fields.Item(strMSSchema & "sendusing") = 1
oCdoConfg.Fields.Item(strMSSchema & "smtpserver") = ""
oCdoConfg.Fields.Item(strMSSchema & "sendusername") = ""
oCdoConfg.Fields.Item(strMSSchema & "sendpassword") = ""
oCdoConfg.Fields.Update
set oCdoMsg = server.createobject("CDO.Message")
oCdoMsg.to = ""
oCdoMsg.bcc = ""
oCdoMsg.from = ""
oCdoMsg.Subject = "A tenant has requested a callback about one of your properties"
oCdoMsg.HTMLbody = mBody
Set oCdoMsg.Configuration = oCdoConfg
oCdoMsg.send
set oCdoMsg = nothing
set oCdoConfg = nothing
response.Redirect("default.asp")
%>
我想知道是否有人能夠發現電子郵件爲什麼不發送電子郵件中的特定屬性詳細信息?
道歉爲相當長的代碼。
謝謝。
在第二頁中添加查詢數據的SQL可能有助於調試。 – 2009-10-06 11:50:31
@foriamstu我剛剛添加了包含在default.asp頁面中的sql查詢。 – doubleplusgood 2009-10-06 11:54:33
字段'request.Form(「fldName」)' – 2009-10-06 11:35:38