为什么这个ASP-EMAIL表单不会发送电子邮件

时间:2012-08-22 21:23:24

标签: asp.net asp-classic

我最近帮助修复了我的ASP EMAIL脚本,但现在我在尝试从CONTACT FORM发送电子邮件时遇到此编译错误。该脚本位于ERROR MESSAGE下方

应用程序中的服务器错误。

编译错误

描述:编译服务此请求所需的资源时发生错误。请查看以下特定错误详细信息并相应地修改源代码。

编译器错误消息:BC30807:不再支持“Let”和“Set”赋值语句。

来源错误:

第10行:如果请求(“发送”)<> ““ 然后 第11行:
第12行:设置objMail = Server.CreateObject(“Persits.MailSender”) 第13行:
第14行:objMail.Host = strHost

源文件:E:\ HostingSpaces \ dma \ myuniversalcare.com \ wwwroot \ contact-us \ Default.aspx行:12

这是脚本:

<% 
    Session.CodePage = 65001 

Dim strHost, objMail, strToAddress, txtMsg 

    ' Change this to your own SMTP server 
    strHost = "localhost" 

    if Request("Send") <> "" Then 

        Set objMail = Server.CreateObject("Persits.MailSender") 

        objMail.Host = strHost 

        objMail.From = "info@persits.com"           ' From address 
        objMail.FromName = "AspEmail Live Demo"     ' optional 

        strToAddress = Trim(Request("txtTo")) 

        ' To prevent header injection attack 
        strToAddress = Replace( strToAddress, " ", "" ) 
        strToAddress = Replace( strToAddress, chr(13), "" ) 
        strToAddress = Replace( strToAddress, chr(10), "" ) 

        ' To address, 2nd argument omitted. 
        objMail.AddAddress strToAddress 

        ' Message subject 
        objMail.Subject = objMail.EncodeHeader( Request("txtSubject"), "UTF-8" ) 

        ' Enable Unicode 
        objMail.ContentTransferEncoding = "Quoted-Printable" 
        objMail.CharSet = "UTF-8" 

        ' Message body 
        objMail.Body = Request("txtBody") 

        ' Include a disclaimer 
        objMail.Body = objMail.Body & chr(13) & chr(10) & chr(13) & chr(10) & "-----------------------------------" & chr(13) & chr(10) & chr(13) & chr(10) & "This message was generated by the AspEmail live demo on-line application. Persits Software, Inc. is not responsible for its content." 

        On Error Resume Next 
        objMail.Send ' Send message 

        If Err = 0 then      
            txtMsg = "<font color=green>Success! Message sent to " & strToAddress + ".</font>" 
        Else         
            txtMsg = "<font color=red>Error occurred: " + err.Description + "</font>" 
        End If 

    End If 
%> 

<HTML> 
<HEAD> 

<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8"> 

<TITLE>AspEmail Live Demo: Unicode-enabled Message Sending</TITLE> 
</HEAD> 
<BODY style="font-family: arial narrow; font-size: 10pt"> 

<h2>AspEmail Live Demo: Unicode-enabled Message Sending</h2> 

<P>  


<FORM METHOD="POST" ACTION="demo_simple.asp"> 

<TABLE CELLSPACING=2 CELLPADDING=2 BGCOLOR="#E0E0E0" style="border: 1pt black solid; border-collapse: collapse"> 
    <TR> 
        <TD>To:</TD> 
        <TD><INPUT TYPE="TEXT" size="40" NAME="txtTo" VALUE="<% = Server.HtmlEncode(Request("txtTo")) %>"></TD> 
    </TR> 
    <TR> 
        <TD>Subject:</TD> 
        <TD><INPUT TYPE="TEXT" size="40" NAME="txtSubject" VALUE="<% = Server.HtmlEncode(Request("txtSubject")) %>"></TD> 
    </TR> 
    <TR> 
        <TD valign="top">Body:</TD> 
        <TD><TEXTAREA NAME="txtBody" Rows="10" Cols="40"><% = Server.HtmlEncode(Request("txtBody")) %></TEXTAREA></TD> 
    </TR> 
    <TR> 
        <TD COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message"></TD> 
    </TR> 

</TABLE> 

<P> 

<% = txtMsg %> 

</FORM> 

</BODY> 
</HTML> 

1 个答案:

答案 0 :(得分:2)

如果您使用的是aspx,则无法使用set。您在aspx页面中有ASP代码。