【问题标题】:How to add CDO reference in an asp web page如何在asp网页中添加CDO引用
【发布时间】:2015-02-24 14:42:11
【问题描述】:
我正在尝试在 asp 中创建一个新电子邮件并使用 CDO 将其发送到邮件服务器。我相信我需要 CDO 或发送电子邮件功能的参考。在书中它说使用这个:
设置 objNewMail = Server.CreateObject("CDONTS.NewMail")
不幸的是,它现在正在工作,因为它在 asp 中出错。现在确定如何添加引用或 com 对象,以便它可以通过使用 asp 的 iis 工作。我指的书是:ASP In a nut shell 2nd add。 “CDO 对象模型”我使用的是 windows xp 或 windows server 2003。
【问题讨论】:
标签:
asp-classic
cdo.message
cdonts
【解决方案1】:
用这个代替 cdonts
<!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%
Function SendMail(sFrom, ToA, Subject, Mybody)
Dim iMsg,iConf
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Dim Flds
Set Flds = iConf.Fields
With Flds
' assume constants are defined within script file
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = MAILSERVER
.Item(cdoSMTPConnectionTimeout) = 60
.Item(cdoURLGetLatestVersion) = True
.Update
End With
With iMsg
Set .Configuration = iConf
.To = ToA
.From = sFrom
.Subject = Subject
.TextBody = Mybody
.Send
End With
Set iConf = nothing
Set iMsg = nothing
If Err.Number = 0 Then
SendMail = True
Else
SendMail = Err.Number&":"&Err.Description
End If
On Error Goto 0
set objSendMail = Nothing
End Function
%>