0

我正在尝试在 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。

4

1 回答 1

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    

%>
于 2011-03-12T04:59:50.280 回答