The basis of the use of CDO objects in Exchange Development (1)

zhaozj2021-02-17  52

Exchange CDO object collection

One: Description of the collection of CDO objects

The CDO object collection is to establish a collaboration is a reliable API of the application, and the ADO can be used to access the web storage system, but he lacks the most basic functions of collaborative jobs, but CDO can handle general applications and advanced workflow applications. Solution, CDO can even provide our ability to manage Exchange and communications with Windows 2000.

CDO: Collaboration Data Objects is a technology that can be used to build a wide range of collaborative job applications, which can be completed, such as accepting delivery email, schedule, contact management, workflow, and Exchange management applications.

CDO is not packaged into a separate object module. Conversely, it contains 3 different object modules, each with its specific use. These item modules can be used alone or alone.

The DLL file information of the three object modules:

CDO for Exchange 2000 Server CDO.dll

CDO for Exchange Management CDOEXM.DLL

CDO Workflow for Exchange CDOWF.DLL

Two: Basic functions of three object modules

1. CDO for Exchange 2000 Server

The most commonly used CDO object module, which includes some of the most common core components and interfaces in collaborative job applications. You can also use the object module to establish a folder in the Web storage system, where the top-level CDO object is often used to establish the following solutions:

Folder: (Folder) in the mailbox storage area or the container of the public storage area.

Personnel: (Person) Web storage system folder information, or users in the AD or contact objects.

Email: (Message) Email

Dating: (Appointment) Already arranged or meeting

Calendar Information (Schedule): (Calendar Message) Conference invitation

Recipient: (addressee) any form of email recipient or recipient for the invitation

Attendance: (attendee) included in the date or personnel

All the uppermost objects have two important common interfaces (Interface)

IConfiguration: Used to define behavior modules that can be applied to multiple objects,

Idatasource: Each CDO object is publicly disclosed, used to manage, store and store information.

2. CDO for Exchange Management Objects

The object module is used to establish and manage the class of Exchange mailboxes with the category of Exchange server components and interfaces. It is often used when writing program code for managing Exchange recipients and mailboxes. The object used is:

ImailRecipient: This object can also receive emails with the contact with the folder without a mailbox to specify how to send the contact with the folder.

ImailboxStore: Specifies how to create, move, delete Exchange mailboxes, and how to manage the properties that you can use to manage the recipient of your mailbox. If the server management tool for the web architecture is developed, the object module provides the object of the overall management server, these conditions available to the top-level objects are:

Exchange Server: Manages Exchange2000 Server and Back Basic Information, such as server type and version. Foldertree: Manage the folder tree structure in which services is used, containing any copies.

StorageGroup: Manage storage groups to organize mailbox storage areas and public storage areas.

MailboxStoredB: Managing a single user's mailbox storage area can use this object to connect, move, or interrupt the connecting mailbox storage area, and pass back basic information about the storage area database.

PublicStoredB: Establish, manage and delete the public storage area and pass the basic information about the storage area database.

3. CDO Workflow for Exchange

The object module is composed of a category and interface for establishing and performing a workflow with the routing application. There are two ways to establish a workflow application:

Method 1: Using Workflow Designer for Microsoft Exchange 2000 Server

Method 2: Use the workflow event flow and event acceptance.

We use the former, using Workflow Designer we don't need most of the workflow objects, only these objects need to be used when writing Script for a variety of workflows, and the most likely objects mostly used in our script as follows:

IWorkflowSession: Provides a workflow engine, the Script of the Action and the Run-Time communication between the workflow items processed.

IWorkflowMessage: Create a notification message to transfer to the recipient in workflow processing.

Audittraileventlog: In the Application Record file (LOG), establish a project (Entries) for workflow event dynamics.

If you use Workflow Designer unable to provide the function to be designed, you must establish an event acceptance. If you build an event acceptance, you need to be familiar with the following objects:

ProcessDefinition: Defines logic in workflows, including status and action.

ProcessInstance: Control, record and monitoring moves between workflow processing, individual independent workflow items.

Three: Start using CDO

1. Established objects by category

CDO consists of a variety of COM's categories, is the basis for establishing a new object. When an object is established, these categories determine the preset function of the object standard. Such as: CDO's Message class is used to define a new Message object, each Message object has the same standard function, allowing objects to be transferred and accepted.

An example of creating a Message object using VB:

DIM msg as cdo.message

Set msg = new cdo.meseage

Create a Message object using VBCript:

DIM MSG

SET MSG = Server.createObject ("cdo.message")

This allows us to access the properties and methods in this category preset interface, and other interfaces disclosed in this category.

Release the memory variables after using the object variable: set msg = Nothing

2. Use interface (interface)

The interface defines a collection that is packaged together by the properties and methods.

Categories usually have multiple interfaces associated with it, including a preset interface, which has a preset function of category. The preset interface is similar to the name of the object, just a letter i before the object name, indicating that this is an interface relative to the category object, such as the IPerson interface that manages all attributes and methods, especially Define information with managing contacts. This preset interface is directly disclosed by its object, that is, we can call properties and methods by objects. We can call the E-mail attribute of the Person object directly, the program code is as follows: DIM PRS AS CDO.PERSON

Set PRS = New CDO.PDO.PERSON

Prs.email=someone@domain.com

In addition to the default interface, most of the categories use at least more than one other interface, which are also used by other categories. The properties and methods can be accessed in the reference interface, which can be easily implemented via call-related properties. If the iDataSource interface is accessed via DataSource, the code is as follows; (VB)

DIM DSRC AS Idatasource

SET DSRC = PRS.DataSource

Some interfaces are not used in accordance with the relevant properties, at this time, different measures are taken because of this sub-situation. If you use VB, you will first declare an object variable as an appropriate interface, and then automatically complete the reference by pointing the interface object variable to the object disclosure. Interface action, such as CDOEXM's ImailRecipient interface

VB: DIM FLD AS CDO.FOLDER

DIM RCP as cdoExm.imailRecipient

SET RCP = FLD

VBScript, you cannot pre-set data types in advance, you must use the GetInterface method to access the interface, and almost every CDO object is publicly used to access the GetInterface method of the interface, the example is as follows:

Set rcp = fld.getInterface ("iMailRecipient")

4: Access structure description attribute

The ADO needs to use the fields object collection to access structural description properties, while CDO provides a simpler way, many compare general structural description properties can be accessed via CDO properties. Such as: We can access the URN: Schema: Contacts: HomePhone Structure Description Properties, the code is as follows:

PRS.HOMEPHONE = "555-555-0101"

There is no equality CDO attribute for structural description properties, and you must use the Adofields object collection, which has the same properties and methods. To access specific properties in an object collection, you will transmit a complete and qualified structure description attribute name. If there is the same CDO-related constant (constant), these constants are starting together with CDO and included in the CDO library, You can use these constants to save the trouble of transferring the full attribute name. When you use the CDO constant to transfer, its name does not need to be added, as follows: Schemas: Contacts: ftpsite's properties:

Prs.fields (cdoftps) = "Somearchive.edu"

If the structure to be accessed Description Attributes There is no available CDO attribute or constant, the full and qualified structural description attribute name is given to the fields object collection. The following example is the same as the above program code:

PRS.FIELDS (URN: SCHEMAS: Contacts: ftpsite) = "Somearchive.edu"

In order to make the program easier to read, we should define your own constants for the application without the CDO attribute or no structure description constant. Five: Using URL

Like ADO, CDO also relies on URL and ExoledB Provider to access resources in the web storage system, and the resources you want to access must be constructed with the correct URL address with the display name (DisplayName), if folder There is a space character in the display name of the path or project, and any space character in the name must be retained in the URL.

CDO also supports relative URL usage.

Six: Understand and use the iDataSource interface

The iDataSource interface is the key to the resource using the CDO to access the web storage system. All CDO objects are exposed to the iDataSource interface via the DataSource property, and the DataSource property can be used to turn the resource, detect and store resources in the web storage system, and build new Resource.

The properties and methods of the iDataSource interface, the following is the properties and methods disclosed in the iDataSource interface.

Seven: The operation of the IDASOSOURCE interface

When using CDO to open a resource, not dynamically connected to the web storage system, but the data is copied by a copy from the Web storage system to the CDO object of the unit, so you will have two information, one to Web In the storage system, in another reply-CDO object, any change in the property method of using the CDO object is a copy of the data on the unit, not the information in the web storage system until the storage method of Idatasource is clearly used. Specifies that the information to change the web storage system will be changed. If you do not call a storage method, the copy of the change will be lost.

Establishing a new resource is also the same.

8: Use CDO to open a resource

Using the DataSource.Open method in the CDO object, it is a method based on the RECORD.Open method. The Open method used by CDO is as follows:

Open (Source URL AS String [, ActiveConnection As Object] [Mode As ConnectModeenum Specifies how Record is turned on]) The default is open in a read-only mode.

Judging whether the source is modified in this unit: the DataSource.IndiRTY property of the iDataSource interface (Boolean value)

You can use this property to determine whether the CDO object of this unit is changed, if change, save the change with the DataSource.save method.

Nine: Establish new resources using CDO

First create a URL for the new resource, then store the relevant information of the new resource to the URL, the DataSource.saveto method allows you to specify the URL of the established resource, the URL must be the precise actual location of the resource, but also the DAV of the resource. : DisplayName.

Syntax of the DataSource.saveto method:

Saveto (SourceURL As String [, ActiveConnevtion As Object] [Mode As ConnectModeenum] [, CreateOptions as RecordcreateOptionSenum])

Mode, specify how Record is turned on

CreateOptions, specify how resources are created, AdcreateOverWrite will override resource items that have been existing on the URL. If this constant is not set, if the URL already exists, an error will be returned.

DataSource.savetocontainer method syntax, the same manifest, and the SaveTo method

Differences: The SaveTo method is the URL and DAV: DisplayName of the specific well-known resource project, then put the resource project to the specified URL, named the specified DAV: DisplayName, and the SaveToContainer method is to put the resource to the specified URL, The resource DAV: DISPLAYNAME is automatically generated by Exchange. The purpose of this method: The Savetrocontainer method is used in the schedule, and it is used in the date of establishment. What happens, we should use the SaveToContainer method.

Ten: Open CDO objects using other objects

You can use the DataSource.OpenObject method to open the CDO object from the objects in other memory, and the object in the memory can be an object of other CDO objects or other libraries, such as ADO2.5.

The syntax of the OpenObject method is as follows:

OpenObject (Soure As Unknown, InterfaceName As String)

Source: The object to be opened, such as an ADO Record or an open email, is usually an object variable

InterfaceName: Source The interface name string, for example, if Source is a Bodypart object of an email, then InterfaceName is Bodypart, this parameter is case sensitive.

Why use this method:

When we have used the RecordSet object to browse the web storage system, you may use the Connection object to perform SQL queries to filter the required items, or batch new projects, but you may need to use CDO to set the object specified by the object. If you want to modify the CDO object that uses the OpenObject method, you need to use the DataSource.saveToObject method to save back to the Parent object, transfer the OpenObject method to the SaveToobject method when saving the OpenObject method.

Check if the folder or project exists:

Using the Open method of Ado Record, open the URL want to check, if it is successful, this URL already has the same resources, if you can't open, then the resource or item does not exist

11: Creating a folder using CDO

When you create a new folder with CDO, you want to create a new CDO Folder object, then set the relevant properties you want to operate, if you want to set a folder to save a specific form, set the ContentClass property. For one of the prior defined content categories, if the folder can be used by the MAPI's client, set http://schemas.microsoft.com/exchange/outlookfolderclass properties, if there is a calling fields collection object to set Depending on the property, please call the UPDATE method first, save it with the SaveTo method.

If you want to delete a folder or a project, you need to call the ReletereoCrd method of Record.

12: Use a folder to receive email

When a folder is established, the preset cannot be accepted by SMTP. You must explicitly turn on the folder to accept email. The MAILENABLE method of the CDO's imaging can reach this. Exchange will automatically specify an email address. folder.

If you want to turn on the folder to receive an email, you must first create the folder that you have just created, then call the MAileNable method. If you use the existing folder, you don't need to store it again. . Routine:

Set fl = creteObject ("cdo.folder")

URL = file: //./backofficestorage/oaserver.exchange/

SET RCP = fl.getInterface ("iMailRecipient")

Fl.DataSource.save

Set fl = Nothing set rcp = nothing

Calculate the contents of the folder:

When using the resources in the ADO calculation folder, you must browse the entire folder. This means ignores the content of the resource is the item or folder, and when the number of resources is large, it will bring considerable load to the server.

Using CDO can avoid unclear conditions in the program, and the server load is too heavy, the Folder object provides three calculation folder content:

ItemCount: This property calculates the number of items that do not contain subfolders in the folder.

UnRead itemcount: This property only calculates the number of items that are not marked as read.

VisableCount: This property only calculates items that users visible and accessible, ignore system hidden items that may be stored in a folder.

转载请注明原文地址:https://www.9cbs.com/read-29525.html

New Post(0)