Platform SDK: Exchange 2000 Server

IConfiguration Interface

[This is preliminary documentation and subject to change.]

The IConfiguration interface defines properties and methods used to access configuration information for CDO objects.

IID
CD000022-8B95-11D1-82DB-00C04FB1625D
Extends
IDispatch

Member Summary

Properties

Name Type Description
Fields

(Read-only)

[Visual Basic]ADODB.Fields

[C++,IDL] Fields*

The Fields collection for the object.

Methods

Name Description
Load Loads the specified configuration.
GetInterface Returns the requested dual interface on the object.

Remarks

You can access configuration settings on implementing objects using the IConfiguration interface. The Fields property references an ADO Fields collection, and each Field object in the collection contains a name/value pair that defines some part of a particular configuration. Consult the appropriate fields section of the reference for a list of valid fields to use. Most field names associated with configuration settings reside in the http://schemas.microsoft.com/cdo/configuration/ namespace.

Example

The following example demonstrates use of the IConfiguration interface on a CDO Configuration object. When sending messages from a machine that does not have an SMTP service installed, we must send the message using an SMTP service on the network. A Configuration object is created, populated with configuration information and then associated with a Message object using the IMessage.Configuration property. The SMTP server name, port, user display name, email address, and credentials are all set as a part of the configuration. The table below lists the values used. Note that a field's fully qualified name must be used when referring to it. For configuration fields, all field names are prefixed with the http://schemas.microsoft.com/cdo/configuration/ namespace. For example, the fully qualified name for the smtpserver field is http://schemas.microsoft.com/cdo/configuration/smtpserver. The namespace prefix is not shown in the table below to preserve space.

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

Field Value
smtpserver mail.microsoft.com
smtpserverport 67
smtpaccountname My Name
sendemailaddress "MySelf" <myself@microsoft.com>
smtpauthenticate cdoBasic (1)
sendusername domain\username
sendpassword password
smtpusessl True (VARIANT_TRUE)
sendusing cdoSendUsingPort (2)

Once the Configuration object has been populated with relevant configuration information, and associated with the Message object, the message is sent. It the examples below, the CdoConfiguration module constants are used to identify the desired field. These constants are simply the full names of the fields in the namespace. For example, the CdoConfiguration constant cdoSMTPServer is equal to the string http://schemas.microsoft.com/cdo/configuration/smtpserver.

[Visual Basic]
Dim iConf as new CDO.Configuration
Dim Flds as ADODB.Fields

Set Flds = iConf.Fields
Flds(cdoSendUsingMethod)          = cdoSendUsingPort ' 2
Flds(cdoSMTPServer)               = "mail.microsoft.com"
Flds(cdoSMTPServerPort)           = 67
Flds(cdoSMTPAccountName)          = "My Name" 
Flds(cdoSMTPAuthenticate)         = cdoBasic ' 1
Flds(cdoSendUserName)             = "domain\username"
Flds(CdoSendPassword)             = "password"
Flds(cdoSendEmailAddress)         = """MySelf"" <myself@microsoft.com>"
Flds(cdoSMTPUseSSL)               = True
Flds.Update
  
Dim iMsg as New CDO.Message
Set iMsg.Configuration = iConf
  ' ... compose message; add attachments, etc
iMsg.Send
  
[C++,IDL]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace raw_interfaces_only
#import "c:\winnt\system32\cdosys.dll" no_namespace raw_interfaces_only
#include "cdosysstr.h"
#include "cdosyserr.h"
#include <atlbase.h>
#include <atlimpl.cpp>

main( ){  
  
  CoInitialize(NULL);
  HRESULT hr = S_OK;
  {
    // Create Configuration Object
    CComPtr<IConfiguration> pConf;
    hr = pConf.CoCreateInstance(L"CDO.Configuration");
 
    CComPtr<Fields> pFields;
    hr = pConf->get_Fields(&pflds);
 
     CComPtr<Field> pfld;
     hr = pFields->get_Item(CComVariant(cdoSMTPServer),&pfld);
     hr = pfld->put_Value(CComVariant("mailserver"));

     hr = pFields->get_Item(CComVariant(cdoSMTPServerPort),&pfld);
     hr = pfld->put_Value(CComVariant((long)67));

     hr = pFields->get_Item(CComVariant(cdoSMTPAccountName),&pfld);
     hr = pfld->put_Value(CComVariant("My Name"));

     hr = pFields->get_Item(CComVariant(cdoSendEmailAddress),&pfld);
     hr = pfld->put_Value(CComVariant("\MySelf\" <myself@microsoft.com>"));

     hr = pFields->get_Item(CComVariant(cdoSTMPAuthenticate),&pfld);
     hr = pfld->put_Value(CComVariant((long)cdoBasic));
     
     hr = pFields->get_Item(CComVariant(cdoSendUserName),&pfld);
     hr = pfld->put_Value(CComVariant("domain\\username"));

     hr = pFields->get_Item(CComVariant(cdoSendPassword),&pfld);
     hr = pfld->put_Value(CComVariant("password"));

     hr = pFields->get_Item(CComVariant(cdoSMTPUseSSL),&pfld);
     hr = pfld->put_Value(CComVariant(VARIANT_TRUE));

    hr = pFields->get_Item(CComVariant(cdoSendUsingMethod),&pfld);
    hr = pfld->put_Value(CComVariant((long)cdoSendUsingPort));

    hr = pFields->Update();

    CComPtr<IMessage> pMsg;
    pMsg.CoCreateInstance(L"CDO.Message");
    pMsg->putref_Configuration(pConf);

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

    pMsg->Send();
    
  }
  CoUninitialize();
}
  
[Visual Basic]
Dim iConf
Set iConf = CreateObject("CDO.Configuration")
Dim Flds as ADODB.Fields
Set Flds = iConf.Fields
Flds(cdoSendUsingMethod)          = cdoSendUsingPort ' 2
Flds(cdoSMTPServer)               = "mail.microsoft.com"
Flds(cdoSMTPServerPort)           = 67
Flds(cdoSMTPAccountName)          = "My Name" 
Flds(cdoSMTPAuthenticate)         = cdoBasic ' 1
Flds(cdoSendUserName)             = "domain\username"
Flds(CdoSendPassword)             = "password"
Flds(cdoSendEmailAddress)         = """MySelf"" <myself@microsoft.com>"
Flds(cdoSMTPUseSSL)               = True
Flds.Update
  
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
Set iMsg.Configuration = iConf
  ' ... compose message; add attachments, etc
iMsg.Send