Microsoft KB Archive/810702

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

Article ID: 810702

Article Last Modified on 11/13/2007

-

APPLIES TO


 * Microsoft Exchange Server 2003 Enterprise Edition
 * Microsoft Exchange Server 2003 Standard Edition
 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft Collaboration Data Objects 2.0 for NT Server
 * Microsoft Collaboration Data Objects 2.0

-





IN THIS TASK

 * Summary
 * Feature comparison
 * Examples
 * Simple send
 * Send HTML body
 * Send with an attachment in MIME format
 * Send with an attachment in Uuencode format
 * Send Unicode message text
 * REFERENCES



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.

Back to the top

Feature comparison
The following table compares operating system (OS) support and feature support in the Cdonts.dll and the Cdosys.dll libraries.

Back to the top

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(&quot;CDONTS.NewMail&quot;) m.Send &quot;user1@company.com&quot;, _ &quot;user2@company.com&quot;, _ &quot;test 1&quot;, _ &quot;hello there&quot;

CDOSYS example
Set m = CreateObject(&quot;CDO.Message&quot;) m.From = &quot;user1@company.com&quot; m.To = &quot;user2@company.com&quot; m.Subject = &quot;test 1&quot; m.TextBody = &quot;hello there&quot; m.send Back to the top

Send HTML body
The following examples put HTML body text in the message. Otherwise, these examples are similar to the &quot;Simple Send&quot; 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 = &quot; &quot; & _ &quot;hello, Red  &quot; Set m = CreateObject(&quot;CDONTS.NewMail&quot;) m.MailFormat = 0 ' CdoMailFormatMime m.BodyFormat = 0 ' CdoBodyFormatHTML m.Send &quot;user1@company.com&quot;, _ &quot;user2@company.com&quot;, _ &quot;test 1&quot;, _ sHTML

CDOSYS example
sHTML = &quot; &quot; & _ &quot;hello, Red  &quot; Set m = CreateObject(&quot;CDO.Message&quot;) m.From = &quot;user1@company.com&quot; m.To = &quot;user2@company.com&quot; m.Subject = &quot;test 1&quot; m.HtmlBody = sHTML m.send Back to the top

CDONTS example
Set m = CreateObject(&quot;CDONTS.NewMail&quot;) m.MailFormat = 0 ' CdoMailFormatMime m.AttachFile &quot;d:\ptsp\test\test.doc&quot; m.Send &quot;user1@company.com&quot;, _ &quot;user2@company.com&quot;, _ &quot;test.doc&quot;, _ &quot;Here is the document you requested&quot;

CDOSYS example
Set m = CreateObject(&quot;CDO.Message&quot;) m.From = &quot;user1@company.com&quot; m.To = &quot;user2@company.com&quot; m.Subject = &quot;test.doc&quot; m.TextBody = &quot;Here is the document you requested.&quot; m.AddAttachment &quot;file://d:\ptsp\test\test.doc&quot; m.send Back to the top

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(&quot;CDONTS.NewMail&quot;) m.MailFormat = 1 ' CdoMailFormatText m.AttachFile &quot;d:\ptsp\test\test.doc&quot; m.Send &quot;user1@company.com&quot;, _ &quot;user2@company.com&quot;, _ &quot;test.doc&quot;, _ &quot;Here is the document you requested&quot;

CDOSYS example
Set m = CreateObject(&quot;CDO.Message&quot;) m.MimeFormatted = false m.From = &quot;user1@company.com&quot; m.To = &quot;user2@company.com&quot; m.Subject = &quot;test.doc&quot; m.TextBody = &quot;Here is the document you requested.&quot; m.AddAttachment &quot;file://d:\ptsp\test\test.doc&quot; m.send Back to the top

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, &quot;€&quot; 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(&quot;CDONTS.Session&quot;) S.LogonSMTP &quot;User 1&quot;, &quot;user1@company.com&quot; s.SetLocaleIDs 65000 ' cpUTF7 Set m = s.Outbox.Messages.Add m.MessageFormat = 0 ' CdoMime set r = m.Recipients.Add 'r.address = &quot;user2@company.com&quot; r.name = &quot;Joe €&quot; r.address = &quot;&quot; m.Subject = &quot;Unicode content&quot; m.Text = &quot;That will be €5, please.&quot; m.Send

CDOSYS example
set m = CreateObject(&quot;CDO.Message&quot;) m.From = &quot;User1 &quot; m.To = &quot;Joe € &quot; m.Subject = &quot;Unicode content&quot; set b = m.bodypart b.charset = &quot;unicode-1-1-utf-7&quot; m.textbody = &quot;That will be €5, please.&quot; m.send Back to the top

