-1

我从一个网站下载了这个源代码,该网站有一个 DEMO 表单,通过下面的这个 SCRIPT 发送电子邮件。但是,当我在我的 arvixe 主机中添加它来为我的联系表单页面发送电子邮件时,我在下面收到这个编译错误

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: BC30451: 'strHost' is not declared. It may be inaccessible due to its protection level.

Source Error:


Line 3:  
Line 4:     ' Change this to your own SMTP server
Line 5:     strHost = "localhost"
Line 6:     
Line 7:     if Request("Send") <> "" Then

Source File: E:\HostingSpaces\dma\myuniversalcare.com\wwwroot\contact-us\default.aspx    Line: 5 

这是脚本:

<%
    Session.CodePage = 65001

    ' 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>
4

1 回答 1

1

该脚本不是为显式模式制作的,它使用变量而不首先声明它们。

为其使用的变量添加声明:

Dim strHost, objMail, strToAddress, txtMsg
于 2012-08-22T21:04:06.800 回答