Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to migrate the Collaboration Data Objects for NTS applications to Microsoft Collaboration Data Objects for Windows 2000


View products that this article applies to.

Summary

This step-by step article describes how to migrate existing code based on the CDONTS object model to CDOSYS.

You can use the Cdonts.dll and Cdosys.dll object libraries to create and process e-mail by using Internet standard formats and protocols. Collaboration Data Objects for NTS (CDONTS) was originally implemented to use with Microsoft Commercial Internet Server (MCIS), and was included in the Windows NT Option Pack. CDONTS was also included as part of Windows 2000 for compatibility with Windows NT. CDONTS is not included with Microsoft Windows XP and subsequent releases of Windows. Microsoft Collaboration Data Objects for Windows 2000 (CDOSYS) was implemented and included as a Windows 2000 operating system component. The existing code that is based on CDONTS must migrate to CDOSYS.

Feature comparison

The following table compares operating system (OS) support and feature support in the Cdonts.dll and the Cdosys.dll libraries.
FeatureCDONTSCDOSYSNotes
Windows NT supportyesnoNeither included with OS
Windows 2000 supportyesyesBoth included with OS
Windows XP supportnoyesCDOSYS only included with OS
Exchange server supportyesyes
Send mailyesyes
Post to newsgroupnoyes
Send (post) by using Simple Mail Transfer Protocol (SMTP) Network News Transfer Protocol (NNTP) port noyes
MIME and Uuencode message formats yesyes
Explicit control of MIME body part structure, encoding, charset, and others. noyes
HTML and MHTML support yesyes
List / read local drop directory noyes
List / read inbox through POP3 yesno
Transport event sink support noyes
Reply and forward functionsnoyes

Examples

The following examples demonstrate how to perform the same task by using CDONTS and by using CDOSYS. Each of the following examples describes a feature that both libraries have, and then gives sample code for implementing the feature in each library. These code samples were verified by using Windows 2000 Service Pack 2 (SP2) and the following versions of the libraries:
  • CDONTS 6.0.3939.0
  • CDOSYS 6.0.3943.3

Simple send

This example is the most popular use for both libraries. In this case, both libraries write the message to the pickup directory of the SMTP server. The directory path is read from the local metabase.
CDONTS example
 set m =
CreateObject("CDONTS.NewMail") m.Send "user1@company.com", _
"user2@company.com", _ "test 1", _ "hello there" 
CDOSYS example
 Set m =
CreateObject("CDO.Message") m.From = "user1@company.com" m.To =
"user2@company.com" m.Subject = "test 1" m.TextBody = "hello there"
m.send

Send HTML body

The following examples put HTML body text in the message. Otherwise, these examples are similar to the "Simple Send" examples. In both sets of examples, MIME multipart/alternative message format is used. Also, a plain text body is automatically created from the HTML. The plain text body is included as a text/plain body part.
CDONTS example
 sHTML = "<html><body><font
color=""#FF0000"">" & _ "hello,
Red</font></body></html>" Set m =
CreateObject("CDONTS.NewMail") m.MailFormat = 0 ' CdoMailFormatMime
m.BodyFormat = 0 ' CdoBodyFormatHTML m.Send "user1@company.com", _
"user2@company.com", _ "test 1", _ sHTML 
CDOSYS example
 sHTML = "<html><body><font
color=""#FF0000"">" & _ "hello,
Red</font></body></html>" Set m = CreateObject("CDO.Message")
m.From = "user1@company.com" m.To = "user2@company.com" m.Subject = "test 1"
m.HtmlBody = sHTML m.send

Send with an attachment in MIME format

CDONTS example
Set m = CreateObject("CDONTS.NewMail") m.MailFormat = 0 ' CdoMailFormatMime
m.AttachFile "d:\ptsp\test\test.doc" m.Send "user1@company.com", _
"user2@company.com", _ "test.doc", _ "Here is the document you
requested"
CDOSYS example
 Set m
= CreateObject("CDO.Message") m.From = "user1@company.com" m.To =
"user2@company.com" m.Subject = "test.doc" m.TextBody = "Here is the document
you requested." m.AddAttachment "file://d:\ptsp\test\test.doc"
m.send

Send with an attachment in Uuencode format

For both libraries, to send the message with an attachment in Uuencode, change a property on the message to change the format.
CDONTS example
 Set m =
CreateObject("CDONTS.NewMail") m.MailFormat = 1 ' CdoMailFormatText
m.AttachFile "d:\ptsp\test\test.doc" m.Send "user1@company.com", _
"user2@company.com", _ "test.doc", _ "Here is the document you requested"
CDOSYS example
 Set m =
CreateObject("CDO.Message") m.MimeFormatted = false m.From =
"user1@company.com" m.To = "user2@company.com" m.Subject = "test.doc"
m.TextBody = "Here is the document you requested." m.AddAttachment
"file://d:\ptsp\test\test.doc" m.send

Send Unicode message text

This example includes a Unicode character (the Euro symbol, �, Unicode code point 0x20ac) in the display name of the recipient and in the message text. In both examples, "�" is encoded into the utf-7 CharSet property. CDONTS must use the CP_UTF7=65000 constant. For CDOSYS, the CharSet name is unicode-1-1-utf-7.
CDONTS example
 Set s = CreateObject("CDONTS.Session") S.LogonSMTP "User 1",
"user1@company.com" s.SetLocaleIDs 65000 ' cpUTF7 Set m = s.Outbox.Messages.Add
m.MessageFormat = 0 ' CdoMime set r = m.Recipients.Add 'r.address =
"user2@company.com" r.name = "Joe �" r.address = "<joe.euro@company.com>"
m.Subject = "Unicode content" m.Text = "That will be �5, please."
m.Send
CDOSYS example
set m =
CreateObject("CDO.Message") m.From = "User1 <user1@company.com>" m.To =
"Joe � <joe.euro@company.com>" m.Subject = "Unicode content" set b =
m.bodypart b.charset = "unicode-1-1-utf-7" m.textbody = "That will be �5,
please." m.send

↑ Back to the top


References

For more information, visit the following MSDN Web sites: For more information, click the following article number to view the article in the Microsoft Knowledge Base:
816789 Read access to the Everyone group is removed after you install Exchange 2000 Service Pack 3

↑ Back to the top


Keywords: KB810702, kbhowto, kbhowtomaster

↑ Back to the top

Article Info
Article ID : 810702
Revision : 7
Created on : 9/3/2013
Published on : 9/3/2013
Exists online : False
Views : 307