简体   繁体   中英

Error in class referring - CDONTS

I get an error at the following line in my application:

'create NewMail object'
Line 96: Function SendHTMLEMail (strFrom, strTo, strCC, strSubject, strBodyHTML)  
Line 97: Set objNewMail = Server.CreateObject("CDONTS.NewMail")

The error is:

Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid class string 
/Utils.inc, line 97

I have added interop.CDONTS.dll to the references of application, but still I am getting same error.

I am not sure if this functionality is used in any other page and is working.

I use .NET 2003 framework 1.1, and the server is running Windows Server 2003

ASP-Classic

Since CDONTS is discontinued since Win2000 and newer you should switch to CDOSYS .

Sample code for sending via remote server

Set oMessage = CreateObject("CDO.Message")
Set oConfig = CreateObject("CDO.Configuration")

Set oFields = oConfig.Fields

With oFields
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.acme.com"
    .Update
End With

With oMessage
    Set .Configuration = oConfig
    .To = "recipient@acme.com"
    .From = "sender@acme.com"
    .Subject = "A Subject Line"
    .TextBody = "A Text body message"
    .Fields.Update
    .Send
End With

The linked site features detailed examples for all kinds of scenarios.

ASP.NET

If you are targeting ASP.NET you should use System.Net.Mail instead of CDO

I got the solution. I added a new CDONTS.dll and registered it using

regsvr32 C:\\SYSROOT\\system32\\cdonts.dll

This solved the problem. No need of adding it to the references.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM