1

我有一些从我的前任“继承”的 ASP 代码(不,此时不能选择更新它......这不仅需要国会,而且需要所有其他国家的行为),我在其中一个页面上发送邮件时遇到问题。这是来自另一页的几乎相同的代码片段,但是当我尝试“发送”时,这个会引发错误。

下面的代码:

Set myMail=CreateObject("CDO.Message")
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2

'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="localhost"

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

myMail.Subject="Subject"
myMail.From=from_email
myMail.To=email
myMail.TextBody= "Body Text of message"
myMail.Send

抛出的错误是:错误类型:(0x8004020F)此订阅的事件类位于无效分区中

我将不胜感激任何和所有的帮助!

谢谢!联合部队

4

2 回答 2

2

我在尝试让 CDO 工作时遇到了类似的问题。我在这个网站上发现了一篇很酷的文章为什么 CDO.Message 给我 8004020F 错误?

这是我终于开始工作的代码。我永远无法让 localhost 作为 SMTP 服务器工作。找出邮件服务器的名称并确保使用该名称。

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Type Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<%
Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
        .Item(cdoSendUsingMethod) = cdoSendUsingPort
        .Item(cdoSMTPServer) = "nameofmailservergoeshere"
        .Update
End With


Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
        Set .Configuration = cdoConfig
        .From = "me@mywebsite.com"
        .To = "you@yourwebsite.com"
        .Subject = "Sample CDO Message"
        .TextBody = "This is a a test message using CDO."
        .Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>

于 2010-06-09T23:48:01.647 回答
1

这似乎是 smtp 服务器的问题...

看看http://forums.aspfree.com/asp-development-5/the-event-class-for-this-subscription-is-in-an-invalid-103189.html

并且

http://www.powerasp.com/info/4558~General~info.htm

于 2010-06-09T21:36:41.260 回答