IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Replace CDONTS with CDOSYS on Classic ASP Pages

Replacing CDONTS with CDOSYS, while can be time consuming for a large classic ASP application, is actually very easy to do. Here’s a simple example of what need to be changed at a minimum:

  1. Set oCDOMail = Server.CreateObject(“CDONTS.NewMail”) to:
    Set oCDOMail = Server.CreateObject(“CDO.Message”)
  2. Remove BodyFormat property, oCDOMail.BodyFormat = 0 since it’s unnecessary.
  3. Replace MailFormat property oCDOMail.MailFormat = 0 with MimeFormatted property oCDOMail.MimeFormatted = True.
  4. You may also want to add Charset property.
    oCDOMail.BodyPart.Charset = “utf-8”
  5. Replace oCDOMail.Body with oCDOMail.HTMLBody.
  6. Replace Importance property oCDOMail.Importance = 1 with oCDOMail.Fields(“urn:schemas:mailheader:priority”).Value = 1

The typical page composition to send email using either object can be seen below:

CDONTS

<%
  Dim oCDOMail
               
  Set oCDOMail = Server.CreateObject("CDONTS.NewMail")
               
  oCDOMail.From = ...
  oCDOMail.To = ...

  oCDOMail.Subject = "CDONTS email"
  oCDOMail.BodyFormat = 0
  oCDOMail.MailFormat = 0
  oCDOMail.Importance = 1
               
  oCDOMail.Body = "<html><body><p>This is a test.</p></body></html>"
               
  oCDOMail.Send
               
  Set oCDOMail = Nothing
%>

CDO

<%
  Dim oCDOMail
               
  Set oCDOMail = Server.CreateObject("CDO.Message")
               
  oCDOMail.From = ...
  oCDOMail.To = ...
  oCDOMail.Subject = "CDO email"
  oCDOMail.BodyPart.Charset = "utf-8"
  oCDOMail.MimeFormatted = True
  oCDOMail.Fields("urn:schemas:mailheader:priority").Value = 1
               
  oCDOMail.HTMLBody = "<html><body><p>This is a test.</p></body></html>"
               
  oCDOMail.Send
               
  Set oCDOMail = Nothing
%>

And here’s the two pages compared side-by-side:
CDONTS vs CDOsys Sendmail ASP Code compared

Since CDONTS was deprecated since Windows 2000, ideally, all applications still using it should be rewritten to use the newer CDO object. However, it’s very common to see many enterprises prefer to make CDONTS work on the newer Windows Server to save time and money from re-writing their legacy applications.

August 18, 2015 Filed Under: How To Tagged With: Cdonts Dll, Classic ASP, Windows, Windows Server

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure