Knowledgebase: ASP Components
Using CDOSYS
Posted by Paul Woodland on 02 January 2014 01:57 PM

CDOSYS is a server-side component that can be used to send emails from our mail servers.  CDOSYS was designed to replace CDONTS on modern server systems, although CDONTS can still be used, it should be replaced with a CDOSYS script. You will first need to enable Script Mail on your website so that you can send emails out via our SMTP server using the username and password that will be assigned to you. For detials on this, please see this article:
https://support.liquidsix.com/index.php?/Knowledgebase/Article/View/89/0/introduction-to-script-mail 


How do you use CDOSYS?
The following is an example of using the Message and Configuration components to send a simple email:

    <%
        'Create instances of our CDOSYS objects.
        Set mailObj = Server.CreateObject("CDO.Message")
        Set confObj = Server.CreateObject("CDO.Configuration")

        'Configure our information.
        Set fields = confObj.Fields
        fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "uk.scriptmail.yourwebservers.com"
        fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YOUR SCRIPT MAIL USERNAME" 
        fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YOUR SCRIPT MAIL PASSWORD"
        fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        fields.Update


        'Configure our test email.
        Set mailObj.Configuration = confObj
        mailObj.From = """Your Name"" <you@yourdomain.com>"
       
        mailObj.Subject = "This is a test email"
        mailObj.TextBody = "This test email is using CDOSYS to send email with LiquidSix Hosting"

        'Add a recipient address.
        mailObj.To = """Target Name"" <target@targetdomain.com>"

        'We need to catch the error.
        On Error Resume Next
        mailObj.Send
        If (Err <> 0) Then
            Response.Write "There was an error sending the email: " & Err.Description
        End If
    %>

(0 vote(s))
Helpful
Not helpful

Comments (0)