Configuration CoClass

Configuration CoClass

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Defines an object used to manage the configuration settings used with other Collaboration Data Objects (CDO).

CLSID

CD000002-8B95-11D1-82DB-00C04FB1625D

ProgID

CDO.Configuration

Type Library

Microsoft CDO for Windows 2000 Library

Microsoft CDO for Exchange 2000 Library

Inproc Server

CDOSYS.DLL, CDOEX.DLL

Threading Model

Both

Implemented Interfaces

IConfiguration Interface

OLE DB Row Access

Remarks

Configuration settings are made up of a set of fields (properties) that are simply name/value pairs. Each field is represented as a Microsoft® ActiveX® Data Objects (ADO) Field object contained in an ADO Fields collection. Most configuration fields used for messaging are in the https://schemas.microsoft.com/cdo/configuration/ namespace. For calendaring applications, you specify a time zone using the urn:schemas:calendar:timezone and urn:schemas:calendar:timezoneid fields, and a calendar folder URL using the "CalendarLocation" field.

To increase performance, you can share a single Configuration object among your other CDO objects, and cache the object for reuse. For example, you can gather the configuration information for a particular user in an ASP application Session_OnStart event, and then store the Configuration object in the ASP Session collection. When each ASP page within the session executes, you can retrieve the Configuration object from the Session collection and attach it to each object. You therefore increase performance by not re-creating and populating a Configuration object for each page or for each object you use.

Examples

Assume that the computer on which this example will run has neither a SMTP service nor Microsoft Outlook® Express installed. In this case, you need to send the message through some SMTP service on the network and must configure the Message object completely. Further assume that the SMTP service through which you intend to send messages requires that you authenticate yourself using basic (clear-text) authentication. An instance of the Configuration Component Object Model (COM) class is created and the configuration fields in the object are set with values such as the required SMTP server name, port, authentication, and user name and password. Additional values are set, such as the e-mail address, account name and reply e-mail address. The values used in the example are listed in the following table. Each field is in the https://schemas.microsoft.com/cdo/configuration/ namespace.

Field Value
smtpserver fakesmtp.example.com
smtpserverport 25
sendusing cdoSendUsingPort (2)
smtpaccountname My Name
sendemailaddress "My Self" <myself@example.com>
senduserreplyemailaddress "Another" <another@example.com>
smtpauthenticate cdoBasic (1)
sendusername domain\username
sendpassword password

After the Configuration object has been populated with relevant configuration information, the object reference is set on a Message object. The Message object uses the configuration information to send the message. In the examples that follow, the fully qualified field names are used to clarify the process. However, there are string constants (as type library modules) in the type library for each of these field names.

[Visual Basic]

' Reference to Microsoft ActiveX Data Object 2.5 Library ' Reference to Microsoft CDO for Exchange 2000 Library Dim iConf as New CDO.Configuration Dim Flds as ADODB.Fields Set Flds = iConf.Fields

' The full field name strings are used below to clarify this process.
' The CDO for Windows 2000 type library contains string modules
' that provide these values as named constants.
' Use these module constants to avoid typos and so forth.

Flds("https://schemas.microsoft.com/cdo/configuration/smtpserver") = "fakesmtp.example.com" Flds("https://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 Flds("https://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort ' CdoSendUsing enum value = 2 Flds("https://schemas.microsoft.com/cdo/configuration/smtpaccountname") = "My Name" Flds("https://schemas.microsoft.com/cdo/configuration/sendemailaddress") = """MySelf"" <myself@example.com>" Flds("https://schemas.microsoft.com/cdo/configuration/senduserreplyemailaddress") = """Another"" <another@example.com>" Flds("https://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic Flds("https://schemas.microsoft.com/cdo/configuration/sendusername") = "domain\username" Flds("https://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" Flds.Update

' The Item property on the Fields interface is the default. ' The Value property on the returned Field interface is the default. ' Fully expanded, each line would appear as follows: ' ' Flds.Item("property").Value = [value]

Dim iMsg as New CDO.Message Set iMsg.Configuration = iConf

' ... Compose message; add attachments and so forth.

' Configuration settings in Config object are used to send the message. iMsg.Send

[C++]

#import "c:\program files\common files\system\ado\msado15.dll" no_namespace #import "c:\program files\common files\microsoft shared\cdo\cdoex.dll" no_namespace

main( ){

CoInitialize(NULL); { IMessagePtr IMsg(__uuidof(Message)); IConfigurationPtr iConfig = Msg->Configuration;

FieldsPtr Flds;
FieldPtr Fld;
Flds = iConfig-&gt;Fields;

// The full strings for field names are used to clarify the process.
// The cdoex.h header file contains BSTR constants that
// can be used to avoid typos and so forth.

Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/smtpserver")]-&gt;Value = _variant_t("fakesmtp.example.com") ;
Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/smtpserverport")]-&gt;Value = _variant_t((long)25) ;
Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/sendusing")]-&gt;Value = _variant_t((int)cdoSendUsingPort) ;
// this value is 2
Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/smtpaccountname")]-&gt;Value = _variant_t("My Name") ;
Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/sendemailaddress")]-&gt;Value = _variant_t("\"MySelf\" &lt;myself@example.com&gt;") ;
Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/senduserreplyemailaddress")]-&gt;Value = _variant_t("\"Another\" &lt;another@example.com&gt;") ;
Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/smtpauthenticate")]-&gt;Value = _variant_t((long)cdoBasic) ;
Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/sendusername")]-&gt;Value = _variant_t("domain\\username") ;
Flds-&gt;Item[_variant_t("https://schemas.microsoft.com/cdo/configuration/sendpassword")]-&gt;Value = _variant_t("password") ;
Flds-&gt;Update();

/*
** These string constants are available in the cdosys.h header file,
** but are not put in the cdosys.tlh file when #import runs.

   const BSTR cdoSMTPServer = = L"https://schemas.microsoft.com/cdo/configuration/smtpserver";

   and so on additionally for each of these:

   cdoSMTPServer
   cdoSMTPAccountName
   cdoSMTPAuthenticate
   cdoSendUsingMethod    (You can use the CdoSendUsing enumeration for this.)
   cdoSMTPServerPort
   cdoSendEmailAddress
   cdoSendUserName
   cdoSendPassword
   cdoSendUserReplyEmailAddress
*/

iMsg-&gt;Configuration = iConfig;

// ... Compose message; add attachments and so forth.

iMsg-&gt;Send();

} CoUninitialize(); }

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.