View Full Version : CDONTS / CDOSYS WinXP
10-08-2003, 01:21 PM
I am using the CDONTS to send email on a event within a site, however we have ust changed servers (Now using XP) and CDONTS does not exist on WinXP. It has been replaced with CDOSYS. Now for short term I have registered CDONTS on the XP machine and all is fine, does anyone have any experience in changing over from NTS to SYS?
10-08-2003, 04:53 PM
Didn't even know there was a CDOSYS.
Just adding the cdonts.dll and using regsvr32 to register it is the easiest way for WinXP. :)
10-09-2003, 10:19 AM
CDOSYS is much more sophisticated then CDONTS, but if you've already got code using the latter and you've registered the DLL then there's little point in you changing your existing code.
However, perhaps you should start developing any *new* code with CDOSYS...
10-11-2003, 06:39 PM
Here's an example, "mail.myDomain.com" is the URL of the SMTP server:
set cdoMessage = Server.CreateObject("CDO.Message")
set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.myDomain.com"
set cdoMessage.Configuration = cdoConfig
cdoMessage.From = myFromAddr
cdoMessage.To = myRecipientList
cdoMessage.Subject = mySubject
cdoMessage.HtmlBody = myBody
on error resume next
if Err.Number <> 0 then
Response.Write("Email send failed: " & Err.Description & ".")
set cdoMessage = Nothing
set cdoConfig = Nothing
You'll notice that in typical MS fashion, they've made a simple task even more difficult to accomplish.
10-11-2003, 07:01 PM
I don't think that's very fair. CDONTS was a very primitive (i.e. limited) version of CDOSYS, and it didn't even allow you to specify an SMTP server or the port (it only worked with an SMTP service running on the localhost on port 25)!!
Although perhaps more verbose, CDOSYS is far more sophisticated, and besides, who in their write mind would write that code out more than once? That's what functions and classes are for!
Here's a class I wrote a while ago which neatly encapsulates CDOSYS - it's pretty self-explanatory, but if you have any questions, just ask. It's not complete (it lacks CC and BCC properties, and Property Get handlers) but they are easy enough to add if you need them.
Private Message, MSF
Const URL = "http://schemas.microsoft.com/cdo/configuration"
Private Sub Class_Initialize()
Set Message = Server.CreateObject("CDO.Message")
Set Message.Configuration = Server.CreateObject("CDO.Configuration")
Set MSF = Message.Configuration.Fields
MSF.Item(URL & "/sendusing") = 2
MSF.Item(URL & "/smtpserverport") = 25
MSF.Item(URL & "/smtpconnectiontimeout") = 10
Private Sub Class_Terminate()
Set Message = Nothing
Set Configuration = Nothing
Public Property Let ServerName(sName)
MSF.Item(URL & "/smtpserver") = sName
Public Property Let Port(sPort)
MSF.Item(URL & "/smtpserverport") = sPort
Public Property Let Timeout(sTimeout)
MSF.Item(URL & "/smtpconnectiontimeout") = sTimeout
Public Property Let [To](sTo)
Message.To = sTo
Public Property Let From(sFrom)
Message.From = sFrom
Public Property Let Subject(sSubject)
Message.Subject = sSubject
Public Property Let Body(sText)
Message.TextBody = sText
Public Sub Send()
EDIT: Just made some code tweaks that I meant to make a while ago... it was written in a hurry...!
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.