IConfiguration Interface
Topic Last Modified: 2006-06-13
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 |
---|---|
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 |
---|---|
Returns the specified dual interface on the object. |
|
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<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@example.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.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