Platform SDK: Exchange 2000 Server

Configuration CoClass

[This is preliminary documentation and subject to change.]

Defines an object used to manage the configuration settings used for messaging.

CLSID
CD000002-8B95-11D1-82DB-00C04FB1625D
ProgID
CDO.Configuration
Type Library
Microsoft CDO for Windows 2000 Library,
Microsoft CDO for Microsoft Exchange Server
Inproc Server
CDOSYS.DLL, CDOEX.DLL
Threading Model
Both

Implemented Interfaces

IConfiguration

OLE DB Row Access

Supported IDataSource Bindings

None

Remarks

Configuration settings are used by the Message object to specify certain behaviors, such as whether messages are sent using an SMTP service pickup directory, or sent through an SMTP service directly over the network. Configuration settings are made up of a set of fields (properties), that are simply name/value pairs. Each field is represented as an ADO Field object contained in an ADO Fields collection. To make them unique, each field name resides in the http://schemas.microsoft.com/cdo/configuration namespace.

To set configurations for Message objects, you modify fields in the associated Configuration object. You can either modify fields in the existing Configuration object or create another and set the Message object's Configuration property to this object.

In many cases, the default configuration settings are enough to send and post messages successfully. The default configuration settings depend upon the software installed on the machine on which you are using the CDO component. When you send messages without associating a Configuration object, these defaults are used. For example, if the machine has the SMTP service installed, the default configuration for sending messages is to write them into files in the SMTP pickup directory. Additionally, various settings can be loaded from Outlook Express if it is installed. Consult the configuration fields section of the reference for more information about default settings.

Depending on the software installed, the defaulting behavior is summarized in the following table.

CDO Default Configuration Hierarchy

Software Installed Defaults Loaded From
CDO for Windows 2000, Outlook Express Default mail account
CDO for Windows 2000, IIS SMTP and NNTP sites
CDO for Windows 2000, IIS, Outlook Express IIS and Outlook Express, sends messages through IIS pickup directory
CDO for Exchange Server Exchange store and Directory Services

Configuration objects are effective for optimizing performance and for conforming values to user preferences. Default configuration information may not be appropriate for certain applications. The Configuration object should be global.

In CDO for Microsoft Exchange Server, you can load information into a Configuration object from a user's Active Directory entry. The following Microsoft® Visual Basic® snippet retrieves email address properties, display name, and other mailbox account information.

Dim Config As New Configuration 
Config.Load(cdoSourceDirectory, "mailto:someone@microsoft.com") 

Configuration objects are useful for ASP applications on the Web, created upon a Session_OnStart event and stored in each user's ASP Session object.

Example

Assume that the machine on which this example will run has neither an SMTP service nor Outlook Express installed. In this case, we need to send the message through some SMTP service on the network and must completely configure the Message object. Further assume that the SMTP service through which we intend to send messages requires us to authenticate ourselves using the basic (clear-text) authentication mechanism. An instance of the Configuration 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 username and password. Additional values are set, such as the email address, account name and reply email address. The values used in the example are listed in the following table:

Namepace: http://schemas.microsoft.com/cdo/configuration

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

Once 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 elucidate the process. However, there are string constants (as type library modules) in the type library for each of these field names.

[Visual Basic]
  Dim iConf as new CDO.Configuration
  Dim iFields as ADODB.Fields
  Set iFields = iConf.Fields
  
    ' The full  field name strings are used below to elucidate 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, etc

  iFields("http://schemas.microsoft.com/cdo/configuration/smtpserver")               = "fakesmtp.microsoft.com"
  iFields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")           = 25
  iFields("http://schemas.microsoft.com/cdo/configuration/sendusing")                = cdoSendUsingPort  ' CdoSendUsing enum value =  2
  iFields("http://schemas.microsoft.com/cdo/configuration/smtpaccountname")          = "My Name"
  iFields("http://schemas.microsoft.com/cdo/configuration/sendemailaddress")     = """MySelf"" <myself@microsoft.com>"
  iFields("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress")= """Another"" <another@microsoft.com>"
  iFields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")         = cdoBasic
  iFields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "domain\username"
  iFields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "password"
  iFields.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 look like this:
  '
  '  iFields.Item("property").Value = [value]
   
  Dim iMsg as new CDO.Message
  Set iMsg.Configuration = iConf
  
  ' ... compose message; add attachments, etc
  
  iMsg.Send   ' Configuration settings in Config object are used to send the message
 
[C++]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import "c:\winnt\system32\cdosys.dll" no_namespace

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

    IFieldsPtr iFields;
    IFieldPtr iField;   
    iFields = iConfig->Fields;

    // The full strings for field names are used to elucidate the process.
    // The cdosys.h header file contains BSTR constants that 
    // can be used to avoid typos, etc
   
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/smtpserver")]->Value               = _variant_t("fakesmtp.microsoft.com") ;
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/smtpserverport")]->Value           = _variant_t((long)25) ;
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/sendusing")]->Value                = _variant_t((int)cdoSendUsingPort) ;  // this value is 2
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/smtpaccountname")]->Value          = _variant_t("My Name") ;
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/sendemailaddress")]->Value     = _variant_t("\"MySelf\" <myself@microsoft.com>") ;
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress")]->Value= _variant_t("\"Another\" <another@microsoft.com>") ;
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")]->Value         = _variant_t((long)cdoBasic) ;
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/sendusername")]->Value = _variant_t("domain\\username") ;
    iFields->Item[_variant_t("http://schemas.microsoft.com/cdo/configuration/sendpassword")]->Value    = _variant_t("password") ;
    iFields->Update();
    
    /* 
    ** These string contants are available in the cdosys.h header file
    ** but are not put in the cdosys.tlh file when #import runs.
    ** 

       const BSTR cdoSMTPServer = = L"http://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
       cdoSendUserPassword
       cdoSMTPUserReplyEmailAddress
    **
    */
   
    iMsg->Configuration = iConfig;

    // ... compose message; add attachments, etc

    iMsg->Send();
    
  }
  CoUninitialize();
}