Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CDONTS / CDOSYS WinXP

    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?
    Toobad

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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.
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    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...
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    185
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's an example, "mail.myDomain.com" is the URL of the SMTP server:

    Code:
           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"
           cdoConfig.Fields.Update
           set cdoMessage.Configuration = cdoConfig
           cdoMessage.From =  myFromAddr
           cdoMessage.To = myRecipientList
           cdoMessage.Subject = mySubject
           cdoMessage.HtmlBody = myBody
           on error resume next
           cdoMessage.Send
           if Err.Number <> 0 then
             Response.Write("Email send failed: " & Err.Description & ".")
           end if
           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.
    Last edited by BrainJar; 10-11-2003 at 07:43 PM.

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Location
    London, UK
    Posts
    411
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.
    Code:
    Class clsEmail 
            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 
            End Sub 
    
            Private Sub Class_Terminate() 
                    Set Message = Nothing 
                    Set Configuration = Nothing 
            End Sub 
            
            Public Property Let ServerName(sName) 
                    MSF.Item(URL & "/smtpserver") = sName 
            End Property 
            
            Public Property Let Port(sPort) 
                    MSF.Item(URL & "/smtpserverport") = sPort 
            End Property 
            
            Public Property Let Timeout(sTimeout) 
                    MSF.Item(URL & "/smtpconnectiontimeout") = sTimeout 
            End Property 
            
            Public Property Let [To](sTo) 
                    Message.To = sTo 
            End Property 
            
            Public Property Let From(sFrom) 
                    Message.From = sFrom 
            End Property 
            
            Public Property Let Subject(sSubject) 
                    Message.Subject = sSubject 
            End Property 
            
            Public Property Let Body(sText) 
                    Message.TextBody = sText 
            End Property 
            
            Public Sub Send() 
                    MSF.Update 
                    Message.Send 
            End Sub 
    End Class
    EDIT: Just made some code tweaks that I meant to make a while ago... it was written in a hurry...!
    Last edited by M@rco; 10-13-2003 at 09:57 AM.
    Marcus Tucker / www / blog
    Web Analyst Programmer / Voted SPF "ASP Guru"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •