如何在asp网页中添加CDO引用

发布于 2024-10-21 23:55:49 字数 311 浏览 1 评论 0原文

我正在尝试在 asp 中创建一封新电子邮件并使用 CDO 将其发送到邮件服务器。我相信我需要 CDO 或发送电子邮件功能的参考。书中说使用这个:

Set objNewMail = Server.CreateObject("CDONTS.NewMail")

不幸的是,它现在可以工作,因为它在 asp 中出错。现在确定如何添加引用或 com 对象,以便它可以使用 asp 通过 iis 工作。我指的书是:ASP In a nut shell 2nd Addition。 “CDO 对象模型” 我使用的是 Windows XP 或 Windows Server 2003。

I'm trying to create a new email in asp and send it to a mail server using CDO. I believe I need a reference for CDO or Send Email functionality. In the book it says use this:

Set objNewMail = Server.CreateObject("CDONTS.NewMail")

Unfortunately that is now working as it errors out in asp. Now sure how to add the reference, or com object so that it will work through iis using asp. The book I'm referring to is: ASP In a nut shell 2nd addition. "The CDO Object Model" I'm using windows xp or windows server 2003.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唔猫 2024-10-28 23:55:49

使用这个代替 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    

%>

use this instead of 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    

%>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文