我的表单重定向到感谢页面,但没有向我发送提交的信息

发布于 2024-12-20 05:40:12 字数 8194 浏览 1 评论 0原文

我被要求将此问题更新为最新的代码和错误。我现在没有收到任何错误,但表单中的信息仍未发送到电子邮件。 asp 与表单位于同一页面上:

asp 代码:

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows Library" -->

<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->

<%
sectionID=8

frmName = request.Form("frmName")
frmEmail = request.Form("frmEmail")
frmPhone = request.Form("frmPhone")
frmAddress = request.Form("frmAddress")
frmReferral = request.Form("frmReferral")
frmCallback = request.Form("frmCallback")
frmEnquiry = request.Form("frmEnquiry")

if len(frmName) = 0 then
    errormessage = "<p><b style=""color: red"">Name field left blank.</b></p>"
elseif len(frmEmail) = 0 then
    errormessage = "<p><b style=""color: red"">E-mail field left blank.</b></p>"
elseif len(frmPhone) = 0 then
    errormessage = "<p><b style=""color: red"">Phone field left blank.</b></p>"
end if

if request.TotalBytes <> 0 and len(errormessage) = 0 then

    if len(frmReferral) = 0 then frmReferral = "(left blank)" end if
    if len(frmCallback) = 0 then frmCallback = "(left blank)" end if
    if len(frmAddress) = 0 then frmAddress = "(left blank)" end if
    if len(frmEnquiry) = 0 then frmEnquiry = "(left blank)" end if

    'send email
    '----------


SUB sendmail( frmName, frmEmail, frmPhone, frmAddress, frmReferral, frmCallback, frmEnquiry )   

Dim objCDO

Dim iConf

Dim Flds    

Const cdoSendUsingPort = 2  

    Set objCDO = Server.CreateObject("CDO.Message")

Set iConf = Server.CreateObject("CDO.Configuration")    

Set Flds = iConf.Fields

With Flds

.Item(cdoSendUsingMethod) = cdoSendUsingPickup

.Item(cdoSMTPServer) = "213.171.216.21"

.Item(cdoSMTPServerPort) = 25

.Item(cdoSMTPconnectiontimeout) = 10

.Update

End With


Set objCDO.Configuration = iConf

    objCDO.To = "[email protected]"
    objCDO.Subject = "Enquiry Form"

     bodyHTML =  "Name:" & vbcrlf _
                & frmName & vbcrlf _
                & vbcrlf _
                & "Email:" & vbcrlf _
                & frmEmail & "" & vbcrlf _
                & vbcrlf _
                & "Phone:" & vbcrlf _
                & frmPhone & "" & vbcrlf _
                & vbcrlf _
                & "Address:" & vbcrlf _
                & frmAddress & "" & vbcrlf _
                & vbcrlf _
                & "How did you hear about us?:" & vbcrlf _
                & frmReferral & "" & vbcrlf _
                & vbcrlf _
                & "Do you require a callback?:" & vbcrlf _
                & frmCallback & "" & vbcrlf _
                & vbcrlf _
                & "Enquiry:" & vbcrlf _
                & frmEnquiry

    'response.Write(bodyHTML)
    'response.End

    objCDO.TextBody = bodyHTML  


objCDO.Send

END SUB

    Set objCDO = Nothing

    Set iConf = Nothing

Set Flds = Nothing

    response.Redirect("contact-thankyou.asp")

end if %>

表单:

<form action="contact.asp" method="post">
                    <table  border="0" cellpadding="2" cellspacing="0" class="text">
                        <tr>
                            <td><p>Name : * </p></td>
                            <td><input name="frmName" id="frmName" type="text" class="textbox" value="<%=frmName%>" size="35" title="Required" /></td>
                        </tr>
                        <tr>
                            <td><p>Email : *</p></td>
                            <td><input name="frmEmail" id="frmEmail" type="text" class="textbox" value="<%=frmEmail%>" size="35" title="Required" /></td>
                        </tr>
                        <tr>
                            <td><p>Phone : *</p></td>
                            <td><input name="frmPhone" id="frmPhone" type="text" class="textbox" value="<%=frmPhone%>" size="35" title="Required" /></td>
                        </tr>
                        <tr>
                            <td><p>Address :</p></td>
                            <td><input name="frmAddress" id="frmAddress" type="text" class="textbox" value="<%=frmAddress%>" size="35" /></td>
                        </tr>
                        <tr>
                            <td><p>How did you hear about us :</p></td>
                            <td><select name="frmReferral" id="frmReferral" class="block" style="width: 180px">
                            <option value=""> - SELECT - </option>
                            <option value="Magazine advert"<%if frmReferral = "Magazine advert" then%> selected="true"<%end if%>>Magazine advert</option>
                            <option value="Booklet advert"<%if frmReferral = "Booklet advert" then%> selected="true"<%end if%>>Booklet advert</option>
                            <option value="Web search"<%if frmReferral = "Web search" then%> selected="true"<%end if%>>Web search</option>
                            <option value="Web directory"<%if frmReferral = "Web directory" then%> selected="true"<%end if%>>Web directory</option>
                            <option value="Newspaper"<%if frmReferral = "Newspaper" then%> selected="true"<%end if%>>Newspaper</option>
                            <option value="TV"<%if frmReferral = "TV" then%> selected="true"<%end if%>>TV</option>
                            <option value="Other"<%if frmReferral = "Other" then%> selected="true"<%end if%>>Other</option>
                            </select>
                            </td>
                        </tr>
                        <tr>
                            <td><p>Do you require a call back :</p></td>
                            <td><select name="frmCallback" id="frmCallback" class="block" style="width: 180px">
                            <option value=""> - SELECT - </option>
                            <option value="Morning"<%if frmCallback = "Morning" then%> selected="true"<%end if%>>Morning</option>
                            <option value="Afternoon"<%if frmCallback = "Afternoon" then%> selected="true"<%end if%>>Afternoon</option>
                            <option value="Not Required"<%if frmCallback = "Not Required" then%> selected="true"<%end if%>>Not Required</option>
                            </select>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top"><p>Enquiry :</p></td>
                            <td><textarea name="frmEnquiry" id="frmEnquiry" cols="27" rows="4" class="textbox" style="width: 180px"><%=frmEnquiry%></textarea></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td align="right"><input name="submit" type="submit" value=" Send " class="submit">
                            &nbsp;&nbsp;&nbsp;
                            <input name="reset" type="reset" class="submit"></td>
                        </tr>
                    </table>
                    <p>&nbsp;</p>
                </form>

如果有任何进一步的帮助,我们将不胜感激。谢谢

I was asked to update this question to the most recent code and error. I now receive no error but the information from the form is still not being sent to the email. The asp is on the same page as the form:

The asp code:

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows Library" -->

<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->

<%
sectionID=8

frmName = request.Form("frmName")
frmEmail = request.Form("frmEmail")
frmPhone = request.Form("frmPhone")
frmAddress = request.Form("frmAddress")
frmReferral = request.Form("frmReferral")
frmCallback = request.Form("frmCallback")
frmEnquiry = request.Form("frmEnquiry")

if len(frmName) = 0 then
    errormessage = "<p><b style=""color: red"">Name field left blank.</b></p>"
elseif len(frmEmail) = 0 then
    errormessage = "<p><b style=""color: red"">E-mail field left blank.</b></p>"
elseif len(frmPhone) = 0 then
    errormessage = "<p><b style=""color: red"">Phone field left blank.</b></p>"
end if

if request.TotalBytes <> 0 and len(errormessage) = 0 then

    if len(frmReferral) = 0 then frmReferral = "(left blank)" end if
    if len(frmCallback) = 0 then frmCallback = "(left blank)" end if
    if len(frmAddress) = 0 then frmAddress = "(left blank)" end if
    if len(frmEnquiry) = 0 then frmEnquiry = "(left blank)" end if

    'send email
    '----------


SUB sendmail( frmName, frmEmail, frmPhone, frmAddress, frmReferral, frmCallback, frmEnquiry )   

Dim objCDO

Dim iConf

Dim Flds    

Const cdoSendUsingPort = 2  

    Set objCDO = Server.CreateObject("CDO.Message")

Set iConf = Server.CreateObject("CDO.Configuration")    

Set Flds = iConf.Fields

With Flds

.Item(cdoSendUsingMethod) = cdoSendUsingPickup

.Item(cdoSMTPServer) = "213.171.216.21"

.Item(cdoSMTPServerPort) = 25

.Item(cdoSMTPconnectiontimeout) = 10

.Update

End With


Set objCDO.Configuration = iConf

    objCDO.To = "[email protected]"
    objCDO.Subject = "Enquiry Form"

     bodyHTML =  "Name:" & vbcrlf _
                & frmName & vbcrlf _
                & vbcrlf _
                & "Email:" & vbcrlf _
                & frmEmail & "" & vbcrlf _
                & vbcrlf _
                & "Phone:" & vbcrlf _
                & frmPhone & "" & vbcrlf _
                & vbcrlf _
                & "Address:" & vbcrlf _
                & frmAddress & "" & vbcrlf _
                & vbcrlf _
                & "How did you hear about us?:" & vbcrlf _
                & frmReferral & "" & vbcrlf _
                & vbcrlf _
                & "Do you require a callback?:" & vbcrlf _
                & frmCallback & "" & vbcrlf _
                & vbcrlf _
                & "Enquiry:" & vbcrlf _
                & frmEnquiry

    'response.Write(bodyHTML)
    'response.End

    objCDO.TextBody = bodyHTML  


objCDO.Send

END SUB

    Set objCDO = Nothing

    Set iConf = Nothing

Set Flds = Nothing

    response.Redirect("contact-thankyou.asp")

end if %>

The form:

<form action="contact.asp" method="post">
                    <table  border="0" cellpadding="2" cellspacing="0" class="text">
                        <tr>
                            <td><p>Name : * </p></td>
                            <td><input name="frmName" id="frmName" type="text" class="textbox" value="<%=frmName%>" size="35" title="Required" /></td>
                        </tr>
                        <tr>
                            <td><p>Email : *</p></td>
                            <td><input name="frmEmail" id="frmEmail" type="text" class="textbox" value="<%=frmEmail%>" size="35" title="Required" /></td>
                        </tr>
                        <tr>
                            <td><p>Phone : *</p></td>
                            <td><input name="frmPhone" id="frmPhone" type="text" class="textbox" value="<%=frmPhone%>" size="35" title="Required" /></td>
                        </tr>
                        <tr>
                            <td><p>Address :</p></td>
                            <td><input name="frmAddress" id="frmAddress" type="text" class="textbox" value="<%=frmAddress%>" size="35" /></td>
                        </tr>
                        <tr>
                            <td><p>How did you hear about us :</p></td>
                            <td><select name="frmReferral" id="frmReferral" class="block" style="width: 180px">
                            <option value=""> - SELECT - </option>
                            <option value="Magazine advert"<%if frmReferral = "Magazine advert" then%> selected="true"<%end if%>>Magazine advert</option>
                            <option value="Booklet advert"<%if frmReferral = "Booklet advert" then%> selected="true"<%end if%>>Booklet advert</option>
                            <option value="Web search"<%if frmReferral = "Web search" then%> selected="true"<%end if%>>Web search</option>
                            <option value="Web directory"<%if frmReferral = "Web directory" then%> selected="true"<%end if%>>Web directory</option>
                            <option value="Newspaper"<%if frmReferral = "Newspaper" then%> selected="true"<%end if%>>Newspaper</option>
                            <option value="TV"<%if frmReferral = "TV" then%> selected="true"<%end if%>>TV</option>
                            <option value="Other"<%if frmReferral = "Other" then%> selected="true"<%end if%>>Other</option>
                            </select>
                            </td>
                        </tr>
                        <tr>
                            <td><p>Do you require a call back :</p></td>
                            <td><select name="frmCallback" id="frmCallback" class="block" style="width: 180px">
                            <option value=""> - SELECT - </option>
                            <option value="Morning"<%if frmCallback = "Morning" then%> selected="true"<%end if%>>Morning</option>
                            <option value="Afternoon"<%if frmCallback = "Afternoon" then%> selected="true"<%end if%>>Afternoon</option>
                            <option value="Not Required"<%if frmCallback = "Not Required" then%> selected="true"<%end if%>>Not Required</option>
                            </select>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top"><p>Enquiry :</p></td>
                            <td><textarea name="frmEnquiry" id="frmEnquiry" cols="27" rows="4" class="textbox" style="width: 180px"><%=frmEnquiry%></textarea></td>
                        </tr>
                        <tr>
                            <td> </td>
                            <td align="right"><input name="submit" type="submit" value=" Send " class="submit">
                               
                            <input name="reset" type="reset" class="submit"></td>
                        </tr>
                    </table>
                    <p> </p>
                </form>

Would appreciate any further assistance with this. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长伴 2024-12-27 05:40:12

没有调用 sendmail 过程。
调用该过程。
例如'发送电子邮件注释行之后

'send email
'----------
Call sendmail( frmName, frmEmail, frmPhone, frmAddress, frmReferral, frmCallback, frmEnquiry )

更新:
删除以下几行,所有这些属性都是完全虚构的:)。这些变量已经在变量 bodyHTML 中。

objCDO.Name = frmName 
objCDO.Phone = frmPhone 
objCDO.Address = frmAddress 
objCDO.Referral = frmReferral 
objCDO.Callback = frmCallback 
objCDO.Enquiry = frmEnquiry 

There is no call to sendmail procedure.
Call the procedure.
e.g. after the 'send email comment line.

'send email
'----------
Call sendmail( frmName, frmEmail, frmPhone, frmAddress, frmReferral, frmCallback, frmEnquiry )

Update:
Remove the following lines, all of these properties are completely fictitious :). These variables have already been in the variable bodyHTML.

objCDO.Name = frmName 
objCDO.Phone = frmPhone 
objCDO.Address = frmAddress 
objCDO.Referral = frmReferral 
objCDO.Callback = frmCallback 
objCDO.Enquiry = frmEnquiry 
疑心病 2024-12-27 05:40:12

看起来您在配置部分中的内容超出了您的需要。您可以在没有配置项的情况下尝试一下吗?还是需要这些?我会尝试一个简单的发送脚本,然后从那里扩展它。

这是我得到以下内容以及通过 CDO 发送电子邮件的其他方法的参考: VBScript电子邮件参考

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Example CDO Message" 
objMessage.From = "[email protected]"
objMessage.To = "[email protected]"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

It looks like you have more than you need in the configuration section. Can you try it without the configuration items or do you need those? I would try a simple send script and then expand it from there.

Here is a reference where I got what is below as well as other ways to send the email via CDO: VBScript Email References

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Example CDO Message" 
objMessage.From = "[email protected]"
objMessage.To = "[email protected]"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文