0

我想使用 Persits.MailSender 对象发送电子邮件。我找到了一个解决方案,并包含此代码,此解决方案有效并创建了对象:

<%
posted = request.form ("submit")
if posted = "Submit" then

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' Customize the following 5 lines with your own information. ''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
vtoaddress =   "_____" ' Change this to the email address you will be receiving your notices.
vmailhost =   Application("ServerAddress") ' Change this to your actual Domain name.
vfromaddress = "_____" ' Change this to the email address you will use to send and authenticate with.
vfrompwd =     "_______________" ' Change this to the above email addresses password.
vsubject =     "ASP Contact Form"     'Change this to your own email message subject.


'''''''''''''''''''''''''''''''''''''''''''
'' DO NOT CHANGE ANYTHING PAST THIS LINE ''
'''''''''''''''''''''''''''''''''''''''''''
vfromname = request.form ("TName")
vbody = request.form ("TBody")
vrplyto = request.form ("TEmail")
vmsgbody = vfromname &"<br>"& vrplyto &"<br>"& vbody

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

objEmail.Username = vfromaddress
objEmail.Password = vfrompwd
objEmail.Host = vmailhost
objEmail.From = vfromaddress
objEmail.AddAddress vtoaddress
objEmail.Subject = vsubject
objEmail.Body = vmsgbody
objEmail.IsHTML = True
objEmail.Send

    vErr = Err.Description
    if vErr <> "" then
        response.write vErr & "<br><br>There was an error on this page."
    else
        response.write "Thank you, your message has been sent."
    End If
Set objEmail = Nothing

response.write "Thank you, your message has been sent."
end if
%>

<html><body>
<form name="SendEmail01" method="post">
<table border=0>
<tr>
            <td>Name:</td>
            <td><input type="text" name="TName" size="30"></td>
</tr>
<tr>
            <td>Email:</td>
            <td><input type="text" name="TEmail" size="30"></td>
</tr>
<tr>
            <td>Body:</td>
            <td><textarea rows="4" name="TBody" cols="30"></textarea></td>
</tr>
<tr>
            <td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</form>
</body></html>

填写所有字段并提交页面后,出现如下错误:

    Persits.MailSender.4 error '800a0004'

Cannot assign requested address.

/contact_form.asp, line 34

请帮我..

4

1 回答 1

-1

我希望这段代码对你有帮助

<%
Class HVMailer
    Private mMail       
    Private Sub Class_Initialize()

            Set mMail = Server.CreateObject("Persits.MailSender")
            mMail.Host = ""
            mMail.Username = ""
            mMail.Password = ""
            mMail.TLS = True


    End Sub

    Public Property Let FromAddress(sFrom)

        mMail.From = trim(sFrom)

    End Property    

    Public Property Let FromName(sFromName)

        mMail.FromName = trim(sFromName)

    End Property    

    Public Property Let ReplyTo(sReply)

        mMail.AddReplyTo trim(sReply), trim(sReply)

    End Property    

    Public Property Let Subject(sSubject)

        mMail.Subject = sSubject

    End Property    

    Public Property Let BodyText(sBodyText)

        mMail.Body = sBodyText

    End Property    

    Public Property Let HTML(bHTML)

        mMail.isHTML = bHTML

    End Property    

    Public Sub AddRecipient(sAddress, sName)

        sAddress = trim(sAddress)
        if mMail.ValidateAddress(sAddress)= 0 Then
            mMail.AddAddress sAddress, sName
        end if 

    End Sub

    Public Sub AddCC(sAddress, sName)

        sAddress = trim(sAddress)
        if mMail.ValidateAddress(sAddress)= 0 Then
                mMail.AddCC sAddress, sName
        end if

    End Sub

    Public Sub AddBCC(sAddress, sName)

        sAddress = trim(sAddress)
        if mMail.ValidateAddress(sAddress)= 0 Then
            mMail.AddBCC sAddress, sName
        end if

    End Sub

    Public Sub AddAttachment(sFile)

        mMail.AddAttachment sFile

    End Sub


    Public function Send()

        On Error Resume Next
        mReturn = True
        mMail.Send
        if Err<>0 Then
            mReturn = false
        end if

        Set mMail = Nothing

        send = mReturn

    End Function


End Class

%>
于 2018-12-28T13:15:49.183 回答