views:

24

answers:

2

I get an error at 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, the server is win server 2003

+3  A: 

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 = "[email protected]"
    .From = "[email protected]"
    .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

Filburt
A: 

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.

RMN