Partager via


IConfiguration Interface

IConfiguration Interface

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. The IConfiguration interface defines properties and methods used to access configuration information for Collaboration Data Objects (CDO) objects.

CLSID

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

Extends

IDispatch

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Member Summary

The following table lists the properties of the IConfiguration interface.

Name Description
Fields Returns the Fields object that contains the currently defined configuration settings. This property is read-only.

The following table lists the methods of the IConfiguration interface.

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

Remarks

You can access configuration settings on implementing objects using the IConfiguration interface. The Fields property references a Microsoft® ActiveX® Data Objects (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 https://schemas.microsoft.com/cdo/configuration/ Namespace.

Examples

The following example demonstrates the use of the IConfiguration interface on a CDO Configuration object. When sending messages from a machine that does not have a SMTP service installed, you 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 https://schemas.microsoft.com/cdo/configuration/ namespace. For example, the fully qualified name for the smtpserver field is https://schemas.microsoft.com/cdo/configuration/smtpserver. The namespace prefix is not shown in the table below to preserve space.

The namespace is https://schemas.microsoft.com/cdo/configuration/.

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

After the Configuration object has been populated with relevant configuration information, and associated with the Message object, the message is sent. In the following examples, 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 https://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.example.com" Flds(cdoSMTPServerPort) = 67 Flds(cdoSMTPAccountName) = "My Name" Flds(cdoSMTPAuthenticate) = cdoBasic ' 1 Flds(cdoSendUserName) = "domain\username" Flds(CdoSendPassword) = "password" Flds(cdoSendEmailAddress) = """MySelf"" <myself@example.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 the Configuration object. CComPtr<IConfiguration> pConf; hr = pConf.CoCreateInstance(L"CDO.Configuration");

CComPtr&lt;Fields&gt; pFields;
hr = pConf-&gt;get_Fields(&amp;pflds);

 CComPtr&lt;Field&gt; pfld;
 hr = pFields-&gt;get_Item(CComVariant(cdoSMTPServer),&amp;pfld);
 hr = pfld-&gt;put_Value(CComVariant("mailserver"));

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

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

 hr = pFields-&gt;get_Item(CComVariant(cdoSendEmailAddress),&amp;pfld);
 hr = pfld-&gt;put_Value(CComVariant("\MySelf\" &lt;myself@example.com&gt;"));

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

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

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

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

hr = pFields-&gt;Update();

CComPtr&lt;IMessage&gt; pMsg;
pMsg.CoCreateInstance(L"CDO.Message");
pMsg-&gt;putref_Configuration(pConf);

// ... Compose message, add attachments, etc.

pMsg-&gt;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.example.com" Flds(cdoSMTPServerPort) = 67 Flds(cdoSMTPAccountName) = "My Name" Flds(cdoSMTPAuthenticate) = cdoBasic ' 1 Flds(cdoSendUserName) = "domain\username" Flds(CdoSendPassword) = "password" Flds(cdoSendEmailAddress) = """MySelf"" <myself@example.com>" Flds(cdoSMTPUseSSL) = True Flds.Update

Dim iMsg Set iMsg = CreateObject("CDO.Message") Set iMsg.Configuration = iConf

' ... Compose message, add attachments, etc. iMsg.Send

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.