Add the messaging functionality in a Web application by using the CDO In Lab B, Performing Basic Exchange 2000 Administrative Tasks by Using CDO for Exchange Management, students will cr
Trang 1Contents
Overview 1
The CDO for Exchange Object Model 8
Adding Messaging Functionality 14
Adding Contact Functionality 24
Adding Calendar Functionality 29
Administering Exchange 2000 by Using
CDO for Exchange Management 44
Lab A: Incorporating CDO for Exchange
Lab B: Performing Basic Exchange 2000
Administrative Tasks by Using CDO for
Review 64
Module 4: Incorporating CDO for Exchange 2000 into a Web Solution
Trang 2to represent any real individual, company, product, or event, unless otherwise noted Complying with all applicable copyright laws is the responsibility of the user No part of this document may
be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation If, however, your only means of access is electronic, permission to print one copy is hereby granted
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property
2000 Microsoft Corporation All rights reserved
Microsoft, Active Directory, ActiveX, FrontPage, Hotmail, JScript, MSN, Outlook, PowerPoint, Visual Basic, Visual C++, Window Media, Visual InterDev, Visual Studio, Win32, Windows, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries
Other product and company names mentioned herein may be the trademarks of their respective owners
Project Lead: Samantha Smith
Instructional Designers: Sangeeta Garg (NIIT (USA) Inc.), Marilyn McCune
Instructional Software Design Engineer: William Rebozo
Subject Matter Experts: Jayme Bowers (ECMS Inc.), John Christian (ECMS Inc.),
Robert Ginsburg (ECMS Inc.), Frederick Volking (ECMS Inc
Technical Contributors: Thomas Rizzo, Brent Ingraham, Navin Kachroo, Robert Brown,
Alex Hopmann, Jim Reitz
Graphic Artist: Kirsten Larson (S&T Consulting)
Editing Manager: Lynette Skinner
Editors: Kelly Baker, Nancy Finch
Copy Editor: Ed McKillop (S&T Consulting)
Production Manager: Miracle Davis
Print Coordinator: Marlene Lambert (Online Training Solutions Inc.)
Online Production Coordinator: Jenny Boe
Test Manager: Eric R Myers
Creative Director, Media/Sim Services: David Mahlmann
Web Development Lead: Lisa Pease
CD Build Specialist: Eric Wagoner
Localization Manager: Rick Terek
Operations Coordinator: John Williams
Manufacturing Support: Laura King; Kathy Hershey
Lead Product Manager, Release Management: Bo Galford
Program Manager, Knowledge Management: Josh Barnhill
Lead Product Manager, Knowledge Management: Janet Wilson
Group Manager, Courseware Infrastructure: David Bramble
Director, Developer Training: Juan Fernando Rivera
General Manager: Robert Stewart
Trang 3Instructor Notes
This module provides students with the information necessary to use Collaboration Data Objects (CDO) to create collaborative solutions based on the Microsoft® Web Storage System The module introduces CDO, discusses the various versions of CDO available with Microsoft Windows® 2000 and Microsoft Exchange 2000 Server, and describes the CDO architecture and the components of the CDO for Exchange 2000 Server object model The module then discusses adding messaging, contact, and calendar functionalities in a Web
Storage System application
After completing this module, students will be able to:
! Describe the various versions of CDO available with Windows 2000 and Exchange 2000
! Describe the CDO architecture and how it is possible to use the architecture
to incorporate CDO into a Web Storage System solution
! Identify the components of the CDO for Exchange object model, and describe how to use them to develop a Web solution
! Add the messaging functionality in a Web application by using the CDO
In Lab B, Performing Basic Exchange 2000 Administrative Tasks by Using CDO for Exchange Management, students will create a new public folder, create a new mailbox, and use CDO for Exchange Management objects to build and mount a new information store
Presentation:
170 Minutes
Labs:
60 Minutes
Trang 4Materials and Preparation
This section provides the materials and preparation tasks that you need to teach this module
Required Materials
To teach this module, you need the following materials:
! Microsoft PowerPoint® file 2019A_04.ppt
! Module 4, “Incorporating CDO for Exchange 2000 into a Web Solution”
Preparation Tasks
To prepare for this module, you should:
! Read all of the materials for this module
! Complete the labs
! Review the section on CDO in the Exchange 2000 Server Software Development Kit (SDK)
Trang 5Module Strategy
Use the following strategy to present this module:
! Introduction to CDO Present a brief overview of CDO Discuss the various versions of CDO Emphasize that whereas previous versions of CDO, such as CDO versions 1.1, 1.2, and 1.2.1, relied on MAPI as the data access and transport format, CDO for Windows 2000 and CDO for Exchange are based on Internet-defined standards
! CDO Architecture Describe the CDO architecture and how it provides access to the Web Storage System and the Active Directory™ directory service
! The CDO for Exchange Object Model Describe the components of the CDO for Exchange object model Describe
the Configuration object and the IDataSource interface, and explain the
purpose of each Emphasize that each top-level CDO object stores a
reference to a central Configuration object through a Configuration
property on an associated interface Explain that all top-level CDO objects
expose an implementation of the IDataSource interface
! Adding Messaging Functionality
Describe the Message object Emphasize that before sending a message, it is
a good practice to resolve each recipient address to avoid getting undeliverable messages Explain how Exchange 2000 resolves a recipient’s address Next, demonstrate how to create and send a message by using the
Message object and the Addressee object Lastly, show how to modify the
Multipurpose Internet Mail Extensions (MIME) content in a message
! Adding Contact Functionality
Describe the Person object and show how to create contacts by using this
object Next, show how to search and display contacts in Exchange 2000 by using CDO and ADO Explain that Exchange 2000 supports the Internet industry vCard standard for obtaining contact information through the CDO
Person object Lastly, show how to export and import contact information
by using the vCard format
Trang 6! Adding Calendar Functionality Start this section by explaining that calendar functions in Exchange 2000 can be used to create single or recurring appointments, meeting requests,
and personal and group scheduling Next, describe the Appointment object
Explain what a recurring appointment is and describe the steps to create it
In the next topic, show how to schedule a meeting request by using the
Appointment and CalendarMessage objects Show how to add attendees
to an appointment and send a meeting request to the specified users Next, explain how time zones work in Exchange 2000 and how to use the
Configuration object to manipulate them Explain that before sending a
meeting request, it is possible check an attendee’s calendar to see when the attendee is available Show how to retrieve an attendee’s free/busy status by
using the GetFreeBusy method of the Addressee object In the last topic,
explain that for recurring appointments, the Web Storage System stores a single instance of the appointment Recurring appointments are expanded into individual instances when the Calendar folder is queried in the Web Storage System Outline the steps for querying and modifying recurring appointments
! Administering Exchange 2000 by Using CDO for Exchange Management
In the last section of this module, discuss some applications that can be developed by using CDO for Exchange Management Next, discuss the COM classes of CDO for Exchange Management model used to programmatically administer Exchange 2000 Lastly, show how to use each
CDOEXM object to enumerate storage groups, public and private stores in
the storage groups, and the folder trees
Trang 7Overview
Exchange Management
You can access items in the Microsoft® Web Storage System by using many protocols and application programming interfaces (APIs).Collaboration Data Objects (CDO) is an API that consists of a powerful set of Component Object Model (COM) components that you can use to manage folders, messages, Microsoft Exchange 2000 Server mailboxes, public stores and public folder hierarchies, appointments, contacts, and all other items in the Web Storage System
After completing this module, you will be able to:
! Describe the various versions of CDO available with Microsoft Windows® 2000 and Exchange 2000
! Describe the CDO architecture and how you can use the architecture to incorporate CDO into a Web Storage System solution
! Identify the components of the CDO for Exchange 2000 Server object model, and describe how to use them to develop a Web solution
! Add the messaging functionality in a Web application by using the CDO
In this module, you will learn
about CDO for Exchange
and how to use CDO to
create collaborative
solutions based on the Web
Storage System
Trang 8With the exception of CDO for Microsoft Windows NT®,previous versions of CDO, such as CDO versions 1.1, 1.2, and 1.2.1, relied heavily on MAPI as the data access and transport format CDO for Windows 2000 and CDO for Exchange are based on Internet-defined standards, such as Simple Mail Transfer Protocol (SMTP) and Network News Transport Protocol (NNTP), and use standardized data-access formats, such as OLE DB and ActiveX® Data Objects (ADO) By using CDO, you can build complete messaging, calendar, and contact management applications that run on Windows 2000 and
Use the latest version of
CDO to build complete
messaging, calendar, and
contact management
applications running on
Windows 2000 and
Exchange 2000
Trang 9Overview of CDO
CDO Is Used for
$ Creating and sending bulk e-mail messages
$ Appending disclaimers or other notices to e-mail messages sent through Exchange
$ Creating personal appointments and group schedules
$ Creating and sending meeting requests to attendees
$ Exporting and importing contact information using the vCard format directly into the Web Storage System or Active Directory
CDO has built-in business logic that you can use to easily access Web Storage System data to create collaborative Web solutions CDO recognizes
standardized Internet content types, such as Multipurpose Internet Mail Extensions (MIME), MIME Encapsulation of Aggregate Hypertext Transfer Protocol Documents (MHTML), vCard, and ICalendar
Some of the solutions, or applications, that you can develop by using CDO include:
! Creating and sending bulk e-mail messages
! Appending disclaimers or other notices to e-mail messages sent through Exchange 2000
! Creating personal appointments and group schedules
! Creating and sending meeting requests to attendees
! Exporting and importing contact information by using the vCard format directly into the Web Storage System or the Active Directory™
directory service
You can also create collaborative Web solutions based on the Web Storage System and Active Directory by using CDO in conjunction with ADO version 2.5 and Active Directory Services Interfaces (ADSI) components ADO and ADSI provide access to the Web Storage System and Active Directory, respectively
Topic Objective
To provide an overview
of CDO
Lead-in
CDO is an API with built-in
business logic that
developers can use to easily
create complex collaborative
applications
Discuss how CDO has
built-in busbuilt-iness logic and
supports standardized
Internet content (such as
MIME, vCARD, and
iCalendar) Describe some
of the applications that can
Trang 10Implementations of CDO
$ Builds bulk mailing, transport protocol event sinks, and Web-based messaging applications
$ Builds powerful Outlook-style collaboration applications using the Web Storage System
$ Creates process definitions and action tables that model your application's workflow processes
$ Administers Exchange mailboxes and servers
Different versions of CDO are available with the installation of Windows 2000 and Exchange 2000
CDO for Windows 2000
CDO for Windows 2000 (Cdosys.dll) has an object model that you can use to develop messaging applications on Windows 2000 CDO for Windows 2000 is based on the SMTP and NNTP standards and is available as a system
component with Microsoft Windows 2000 Server installations It is the standard API that you can use for building bulk mailing, transport protocol event sinks, and Web-based messaging applications on Windows 2000 Server
CDO for Windows 2000 provides enhanced functionality as compared to the current CDO for Windows NT Server library, which is available through Windows NT version 4.0 Option Pack 1 Although CDO for Windows 2000 provides the same functionality as CDO for Microsoft Windows NT Server, with some additional features, it is important to modify any code written for CDO for Windows NT Server for it to work with CDO for Windows 2000
CDO for Exchange
CDO for Exchange (Cdoex.dll) is installed with Exchange 2000 CDO for Exchange upgrades the registration for CDO for Windows 2000 to CDO for Exchange Applications based on CDO for Windows 2000 remain intact because CDO for Exchange includes full functionality of CDO for Windows 2000
CDO for Exchange uses Internet standards and OLE DB data access to obtain and manipulate data in the Web Storage System, but is not based solely on the MAPI protocol, as was the previous version of CDO When CDO for
Exchange is installed, all of the existing CDO 1.2 and MAPI applications will port to Exchange 2000 and will work concurrently with applications based on CDO for Exchange
Topic Objective
To describe the versions
of CDO
Lead-in
Various versions of CDO
are available with the
installation of Windows 2000
and Exchange 2000
The previous version of
CDO (1.2.1), available with
Exchange 5.5 has been
completely remodeled and
is no longer dependent on
the MAPI protocol
Discuss each current
version of CDO Explain
how CDO for Windows 2000
and CDO for Exchange
relate to previous versions
of CDO Discuss CDO
Workflow Objects and CDO
for Exchange Management
giving examples of each
Trang 11CDO for Exchange expands the functionality of the CDO for Windows 2000 messaging components to include objects for calendar and contact management Thus you can build powerful Web applications in the style of Microsoft
Outlook® 2000 by using the Web Storage System CDO for Exchange is a server-based object model that can be used only on a computer running Exchange 2000
CDO WorkFlow Objects
CDO Workflow Objects for Exchange 2000 Server provides the tools you need
to add workflow to applications that access data from the Web Storage System Driven by the Web Storage System event architecture, CDO Workflow Objects has a built-in workflow engine and custom COM components that you can use
to model your application's workflow processes
CDO for Exchange Management
CDO for Exchange Management (Cdoexm.dll) is installed with Exchange 2000 and consists of a set of objects for administering Exchange 2000 servers By using CDO for Exchange Management, you can programmatically manage items in Exchange 2000, such as public stores, mailbox stores, folder trees, and storage groups You can use CDO for Exchange Management for server applications that are typically used in Internet applications, such as automatic registration of users, and creating and managing e-mail accounts You can also install CDO for Exchange Management on a client computer to enable remote administration of Exchange 2000
Trang 12CDO Architecture
Visual Basic, Visual C++, JScript, VBScript Application
OLE DB Provider for Exchange 2000
! ADO and OLE DB database access CDO uses ADO version 2.5 and OLE DB to access Exchange 2000 items (contacts, messages, and calendar) in the Web Storage System After ADO and OLE DB retrieve a record or recordset, CDO can bind to individual records for easy manipulation For example, you can use ADO to retrieve messages in a user’s Inbox and then bind to individual messages by using CDO to access the properties of each message
! ADSI You can use CDO and ADSI objects together to create new users and mailboxes, manage users, and contact information in Active Directory By using ADSI, you can also easily identify the URLs with a particular user's mailbox folders, such as their Inbox, Calendar, Drafts, and Contacts folders
! DS OLE DB Provider You can use DS OLE DB Provider that ships with ADSI for Windows 2000
to interact quickly and easily with Active Directory
! Internet protocols CDO uses the Internet Message Access Protocol (IMAP4), Post Office Protocol 3 (POP3), SMTP, NNTP, and Lightweight Directory Access Protocol (LDAP) protocols to access resources in the Web Storage System and Active Directory
Topic Objective
To show the CDO
architecture
Lead-in
CDO is layered over
Exchange 2000 and Active
Directory as shown in
the slide
Delivery Tip
Use the illustration in the
slide to explain how to use
different languages when
communicating with CDO
objects and how CDO uses
ADSI, the DS OLE DB
Provider, and the OLE DB
Provider for Exchange to
communicate with Active
Directory and Exchange
2000 Stress how CDO can
use Internet protocols, such
as SMTP and NNTP to
interact with standardized
Internet, content such as
MIME and ICalendar
Trang 13! Supported content
CDO supports standardized Internet content such as MIME, MHTML, Internet standard e-mail (RFC822), Internet standard news (RFC977), vCard, and ICalendar CDO can bind directly to any of these content types for manipulation For example, CDO can bind to the MIME content of an e-mail message and then extract or modify the properties of that content
For more information on RFC822 and RFC977 standards, go to http://www.ietf.org/rfc.html
Note
Trang 14# The CDO for Exchange Object Model
You can use CDO for Exchange to manage all aspects of message creation and modification You can work directly with contacts, appointments, folders, and specific items that are stored in the Web Storage System Additionally, CDO for Exchange has programming logic built into the object model that you can use to create and manipulate items in the Web Storage System to create complex applications in Exchange 2000 with minimal code
Topic Objective
To list the topics related to
the CDO for Exchange
object model
Lead-in
CDO for Exchange has
programming logic built into
the object model that you
can use to create complex
applications in Exchange
2000, with minimal code
Trang 15Components of the CDO for Exchange Object Model
Item
Configuration IDataSource
Recurrence Patterns
Fields
Appointment
Configuration IDataSource Fields
Exceptions Attendees BodyParts
Fields
Message
Configuration IDataSource BodyParts
Messages
(DropDirectory)
Addressee
Configuration IDataSource Fields
CalendarParts
IDataSource Message
Fields
CalendarMessage Person
Configuration IDataSource Fields Configuration
The CDO for Exchange object model consists of the following components:
! Configuration object You use the Configuration object to manage the
configuration settings for all CDO objects
! Fields collection You use the Fields collection to reference an ADO Fields
collection Each Field object in the collection contains a name/value pair
that defines property values of a particular CDO object
! Message object You use the Message object to create, send, respond to, and
manage message items in the Web Storage System
! Person object You use the Person object to create and manage user and
contact information in the Web Storage System and Active Directory
! Addressee object You use the Addressee object to resolve addresses in
Active Directory and a Contact folder in the Web Storage System You can also retrieve a user's free/busy status
! Appointment object You use the Appointment object to create and manage
appointment items in the Web Storage System
! CalendarMessage object You use the CalendarMessage object to create,
send, reply to, and manage messages in the Web Storage System that contain calendar-related information
! Folder object You use the Folder object to manage folder items in the Web
Storage System
! Item object You use the Item object to access items in the Web Storage
System The Item object is similar to an ADO Record object
Topic Objective
To identify the components
of the CDO for Exchange
object model
Lead-in
The components of the
CDO for Exchange object
model are Message,
Person, Addressee,
Appointment,
CalendarMessage, Folder,
and Item
Briefly describe each object
in the CDO for Exchange
object model and discuss its
function Point out what the
IDataSource interface and
Configuration object have
in common to lead into the
next topic
Trang 16The Configuration Object
Top-Level Objects
Messages, Paths to the SMTP and NNTP Servers, and a User's Mailbox URI
Gathered from Exchange
The default configuration information for all CDO top-level objects is stored in
a central Configuration object A Configuration object contains information,
such as the methods used to deliver messages, the paths to the SMTP and NNTP servers, and the Uniform Resource Identifier (URI) of a user's mailbox
You can associate CDO objects with a Configuration object through their
Configuration properties
Configuration information is stored in an ADO Fields collection in the
Configuration object Most Configuration fields reside in the
“http://schemas.microsoft.com/cdo/configuration/” namespace
When you create a Configuration object, CDO uses the default configuration
information by collecting information from Exchange If you do not create a
Configuration object, CDO creates one each time you send or post a message
Changing Default Configuration
You cannot permanently change the default configuration by using the
Configuration object To change configuration information for a Message, Contact, or Appointment object, you must modify the fields in the Configuration object associated with each object After the task with the object
is complete, the Configuration object is reset to its default properties
Using a Single Configuration Object
To use a single configuration for a set of messages, you can create a new
Configuration object, modify the fields, and then reference this Configuration
object in all the intended messages
When you send many messages, it is a good practice to create a single
Configuration object and use it with each Message object to optimize
application performance For example, by using CDO in an Active Server
Pages (ASP) application, you can store the Configuration class instance in the
Session object, and then reuse it for each message sent during that session
change the default
information for a CDO
object Describe some
common default settings,
such as SMTP server and
SMTP server port Discuss
the properties listed in the
table in the student notes
and describe the code
example Explain how to
create a Configuration
object, configure it, and then
assign it to a CDO object,
such as a message
Trang 17Configuration Object Properties
The following table lists the most frequently used properties of the Configuration object and their associated named constants
Configuration property Named constant Description sendusing cdoSendUsingMethod Used to specify whether to send the
message by using the local SMTP service drop directory (cdoSendUsingPickup), over the network using the SMTP protocol (cdoSendUsingPort), or by using the Exchange mail submission URI (cdoSendUsingExchange)
postusing cdoPostUsingMethod Used to specify whether to post the
message using the local NNTP service drop directory (cdoPostUsingPickup), over the network using the NNTP protocol (cdoPostUsingPort), or by using the Exchange mail submission URI (cdoPostUsingExchange)
smtpserver nntpserver
cdoSMTPServer cdoNNTPServer
Used to indicate the Domain Name System (DNS) name of the SMTP or NNTP service host, if messages are sent by using the SMTP/NNTP protocols
smtpserverport nntpserverport
cdoSMTPServerPort cdoNNTPServerPort
Used to indicate the TCP/IP port of the SMTP or NNTP service, if messages are sent using the SMTP/NNTP protocols
Trang 18Using the Configuration Object to Configure a Message
The following VBScript code creates a Configuration object, modifies the properties of the object through the ADO Fields collection, updates the Fields collection, and assigns the Configuration object to a Message object through its Configuration property:
Dim objConfiguration Set objConfiguration = CreateObject("CDO.Configuration") Set Flds = objConfiguration.Fields
Flds(cdoSendUsingMethod) = cdoSendUsingPort Flds(cdoSMTPServer) = "mail.contoso.msft"
Flds(cdoSMTPServerPort) = 25 Flds(cdoSendUserName) = "domain\username"
Flds(cdoSendPassword) = "password"
Flds(cdoSMTPAuthenticate) = cdoBasic Flds(cdoSendEmailAddress) = """Someone""" & _
"<someone@microsoft.com>"
Flds.Update
Dim Msg Set Msg = CreateObject("CDO.Message") Set Msg.Configuration = objConfiguration ' compose message; add attachments, etc Msg.Send
Trang 19The IDataSource Interface
Web Storage System, ADO Objects, ADSI Objects, and Other CDO Objects
of This Interface
System and Other Objects by Using
$ IDataSource.Open
$ IDataSource.SaveTo
$ IDataSource.SaveToContainer
The CDO object model uses the IDataSource interface to access data in other
ADO, CDO, and ADSI objects, or to access the data in the Web Storage System
and Active Directory All top-level CDO objects (Item, Appointment,
Message, Addressee, CalendarMessage, and Person) expose an
implementation of this interface You can bind (associate or link two objects at
run time) CDO objects to Web Storage System items, ADO objects, ADSI objects, and other CDO objects by using the methods of the
IDataSource interface
When you use CDO to create an item in the Web Storage System or Active Directory, you create a CDO object, modify its properties or streams, and then bind the object to a new URL, or an existing URL to store the item in the Web Storage System To manipulate an existing item in the Web Storage System, you create a CDO object, bind it to an existing URL, change properties on the CDO object, and then save the changes back to the URL
You can bind CDO objects to items in the Web Storage System by using the following methods:
! IDataSource.Open
The Open method first binds the specified store item, which is identified by
a URL, and then copies the data to the CDO object
! IDataSource.SaveTo
The SaveTo method first binds the item and then saves the current data
stored in the CDO object to the store item
! IDataSource.SaveToContainer
The SaveToContainer method is similar to SaveTo, except that you only
need to specify the folder in which to save the item If you do not specify an actual name for the item you are saving to a folder using this method, a globally unique identifier (GUID) is generated internally to identify the item
interface, which is used to
access data in other ADO,
CDO, and ADSI objects, or
is used as saved data in the
Web Storage System and
Active Directory
Discuss how the
IDataSource interface
provides all CDO objects
with access to data from a
variety of sources Discuss
the SaveTo and
SaveToContainer methods
and explain the difference
between the two
Trang 20# Adding Messaging Functionality
Exchange 2000 provides a powerful messaging operating environment for users
to send and receive e-mail messages by supporting a variety of protocols, including Hypertext Transfer Protocol and Web Distributed Authoring and Versioning (HTTP/WebDAV), Microsoft OLE DB Provider for Exchange 2000 Server, SMTP, NNTP, IMAP4, and MAPI
The CDO for Exchange component provides a set of COM classes that you can use in your application to create, access, modify, and send messages in
standardized Internet content, such as MIME, vCard, and ICalendar
CDO for Exchange provides
a set of COM classes that
you can use in your
application to create,
access, modify, and send
messages in standardized
Internet content
Trang 21The Message Object
Address a Message, Add Content, Send, Post, or Respond to a Message
Access MIME Content in a Message
Recipients of Messages
Message
You can use the Message object's properties and methods to create and manage messages The primary and default interface on the Message object is the
IMessage interface You can use this interface to access the messaging-specific
functionality of the object, including addressing the message, adding content,
and sending, posting, or responding to a message The Message object also supports the IBodyPart(s) interface that you can use to access the MIME
The Message object has
properties and methods with
which to create and
manage messages
Introduce the Message
object and describe its
purpose Discuss the
IBodyPart interface it
exposes and describe how
to use it to access the MIME
content of a message
Discuss each property and
method listed in the tables in
student notes Be sure to
discuss the
CreateMHTMLBODY
method
Trang 22Message Object Properties
The following table lists frequently used properties of the Message object that
you use to access its associated values
Property Description Attachments The collection of attachments for a message
CC The informational (carbon copy, or Cc) recipients for a message
Configuration The Configuration object for a message
From The address of the message sender
HTMLBody The HTML representation of the body of a message
MIMEFormatted Indicates whether the message is to be formatted using MIME
Organization A description of the organization to which the sender belongs
ReceivedTime The date/time a message was delivered to the server
ReplyTo The address to which the replies to a message are to be sent
Sender The address of the sender of a message
SentOn The date/time a message was sent to the server
Subject The subject of a message
TextBody The plain text representation of the body of a message
To The recipients of the message
BodyPart Returns the iBodyPart interface of a message object
Message Object Methods
The following table lists the frequently used methods of the Message object
Method Description AddAttachment Adds an attachment to a message The method accepts a
file, File Transfer Protocol (FTP), HTTP, or URL parameter that identifies the location of the attachment
Forward Creates and returns another message that can be used to
forward a message
Post Submits a message to the specified newsgroups
Reply Creates and returns another message that can be used to
reply to the sender of a message
ReplyAll Creates and returns another message that can be used to
reply to the sender and all recipients
CreateMHTMLBODY Converts the contents of an entire Web page into
MHTML-formatted body parts on this message
Trang 23Resolving a Recipient's Address
Directory or a Contact Folder
Entry, It Is Considered to Be Ambiguous
Before attempting to send a message, it is a good practice to resolve each
recipient address to avoid undeliverable messages You can use the Addressee
object to resolve addresses for recipients of messages When Exchange 2000 resolves an address, it checks the address against Active Directory or a Contact folder If the address is found in a Contact folder or Active Directory, the address is considered resolved
If an address can be matched with more than one entry in a Contact folder or Active Directory, the address is considered to be ambiguous In such a case, you can enumerate a collection to display all the matching names
Addressee Object Properties
The following table lists frequently used properties of the Addressee object
Name Description DirURL Contains the directory URL to the resolved user object in Active
Directory
DisplayName Contains the display name of an addressee
EmailAddress Contains the e-mail address of an addressee
ResolvedStatus Indicates the resolution status of an addressee Possible values
include cdoUnResolved (0), cdoResolved (1) and cdoAmbiguous (2)
resolve each recipient
address to avoid getting
undeliverable messages
Introduce the Addressee
object and discuss how to
use it to resolve e-mail
addresses and display
names of users in Active
Directory or a Contact
folder Discuss each
property and method listed
in the tables in the student
notes
Trang 24Addressee Object Methods
The following table lists frequently used methods of the Addressee object
Name Description CheckName Attempts to resolve an addressee directory object using the
information specified in the object
GetFreeBusy Gets the free/busy information for a resolved attendee
AmbiguousName A collection of all addressees that match the ambiguous criteria
used to resolve a particular addressee
Trang 25Creating and Sending a Message
Exchange 2000
To: suzan@microsoft.com ; someone@microsoft.com
Team.Schedule.doc
Word Attachment
Word Attachment
The following VBScript code will resolve a recipient address by using the
Addressee object when you create a message and use the AddAttachment
method of the Message object to add a Graphics Interchange Format (GIF)
graphic, a Microsoft Word file, and an MHTML file as attachments to the message
Dim Addressee Set Addressee = CreateObject("CDO.Addressee") 'enter the email address to resolve
Dim Msg Set Msg = CreateObject("CDO.Message") With Msg
.Newsgroups = "contoso.public.newsgroup1"
.Post End With (code continued on following page)
Topic Objective
To show how to create and
send a message by using
the Message object
Lead-in
The following VBScript code
shows how to send an
e-mail message with
attachments and how to
resolve a recipient’s address
by using the Addressee
object
Delivery Tip
Scroll through each line of
code in the example and
explain each property and
method as it is used
Trang 26Case 2 'cdoAmbiguous Dim Addressee2 For Each Addressee2 In Addressee.AmbiguousNames MsgBox "The name entered matches " & _ Addressee2.DisplayName & _
" whose e-mail address is " & _ Addressee2.EmailAddress
Next Case 0 'cdoUnresolved MsgBox "User does not exist"
End Select
Trang 27Accessing and Manipulating the MIME Content
Object That Represents the MIME Content of the BodyPart
Object
Set iBodyParts = iBodyPart.AddBodyPartiBodyParts.Fields _
("urn:schemas:mailheader:content-type")="text/plain"iBodyParts.Fields.Update
Set Strm = iBodyParts.GetDecodedContentStreamStrm.WriteText "This is the message in text"
Strm.Flush
Set iBodyParts = iBodyPart.AddBodyPartiBodyParts.Fields _
("urn:schemas:mailheader:content-type")="text/plain"iBodyParts.Fields.Update
Set Strm = iBodyParts.GetDecodedContentStreamStrm.WriteText "This is the message in text"
Strm.Flush
MIME enables you to create messages with embedded complex content, such as images, Word documents, and multimedia files A MIME-formatted message has mail header fields and is subdivided into body parts
! Mail header fields describe aspects of each message body part The header
fields can have information on the content in the body, the encoding used, and a base URI for resources referenced in HTML content.
! Body parts contain parts of a message, such as an image, a spreadsheet, a
sound file, an executable (.exe) program, or plain text that represents these items for applications that cannot interpret them
Each BodyPart object can contain some part of a Message object's content,
whether it is an attachment or a part of a MIME hierarchy of content You use
the BodyPart object to access and modify the MIME content of a message
By default, the CDO components create message body content by using MIME
encoding format When using methods such as Message.CreateMHTMLBody
or Message.AddAttachment, the MIME hierarchy is automatically
constructed
Topic Objective
To show how to modify the
MIME content in a message
Lead-in
Use MIME to create
messages with embedded
complex content By default,
the CDO components
create message body
content by using MIME
encoding format
Describe the architecture of
MIME (header and body
parts) and how you can use
the BodyPart object to
access the MIME content of
a message Discuss how
you can use the ADO
Stream object when
accessing the MIME content
of a message Discuss each
property and method listed
in the tables in the student
notes, and then walk
through each line of code in
the example
Trang 28BodyPart Object Properties
The following table lists and has descriptions of some common properties of the
BodyPart object
Property Description BodyParts The BodyParts collection for this object
Charset The character set for the text-type body parts
ContentClass The content class for the body part
ContentMediaType The content type and subtype of the body part
ContentTransferEncoding The encoding mechanism used when encoding the body
part content
BodyParts The BodyParts collection for this object
DataSource The IDataSource interface on the object
Fields The Fields collection for the object
FileName The file name parameter attribute commonly used with
the Content-Disposition header field
Parent The parent body part object for the object
BodyPart Object Methods
The BodyPart object has the following methods:
Method Description AddBodyPart Adds a BodyPart object to the BodyParts collection
and returns a reference to the newly added object
GetDecodedContentStream Returns an ADO Stream object (exposing the _Stream
interface) containing the body part content in decoded format
GetEncodedContentStream Returns an ADO Stream object (exposing the _Stream
interface) containing the body part content in encoded format
GetFieldParameter Returns the specified parameter value for the specified
MIME header field
GetInterface Returns the specified dual interface on the object
GetStream Returns an ADO Stream object (exposing the _Stream
interface) containing the body part content
SaveToFile Saves the decoded body part content to a disk file
Modifying the MIME Content of a BodyPart Object
A BodyPart object has methods that generate an ADO Stream object that represents the MIME content of the BodyPart You can use the ADO stream to modify the BodyPart object
To access the content of the BodyPart, use the GetEncodedContentStream and GetDecodedContentStream methods To access the entire BodyPart MIME-formatted stream, including the header information, use the GetStream
method
Trang 29The following VBScript code creates a Message object, and adds BodyPart
objects to the message by using an ADO stream to manipulate and save the
changes back to the BodyPart
Dim Msg, iBodyPart, iBodyParts, Strm Set Msg = CreateObject("CDO.Message") 'Get IBodyPart on the Message object Set iBodyPart = Msg.BodyPart
'Set the Message object's Content-Type header 'to multipart/alternative
iBodyPart.Fields("urn:schemas:mailheader:content-type") = _
"multipart/alternative"
iBodyPart.Fields.Update 'Add the body part for the text/plain part of message Set iBodyParts = iBodyPart.AddBodyPart
iBodyParts.Fields("urn:schemas:mailheader:content-type") = _
"text/plain"
iBodyParts.Fields.Update 'Get the stream and add the message Set Strm = iBodyParts.GetDecodedContentStream Strm.WriteText "This is the message in text format"
Strm.Flush 'Add the body part for the text/html part of message Set iBodyParts = iBodyPart.AddBodyPart
iBodyParts.Fields("urn:schemas:mailheader:content-type") =
"text/html"
iBodyParts.Fields.Update 'Get the stream and add HTML text to it Set Strm = iBodyParts.GetDecodedContentStream Strm.WriteText "<HTML><H1>This is the message in HTML</H1></HTML>"
Strm.Flush Msg.To = "suzan@microsoft.com"
Msg.From = "paulwe@microsoft.com"
Msg.Send
Trang 30# Adding Contact Functionality
ADO
A contact is a collection of information about a person or business, such as
telephone numbers, e-mail addresses, and pager numbers You can store contact information in Exchange 2000 or Active Directory or both
The Person object is a tool for managing contact items in the Web Storage
System or Active Directory Following are some of the benefits of using the
Person object in the Web Storage System:
! The Person object enables faster development by creating and managing
contact information stored in the Web Storage System and Active Directory
! The Person object enables easy conversion of contact information into the
Internet industry vCard format
! The ability to manipulate contact information through the CDO Person
object and Outlook 2000
Topic Objective
To list the topics related to
adding contact functionality
Lead-in
Use the Person object to
manipulate contact
information in the Web
Storage System and in
Active Directory
Trang 31Creating Contacts by Using the Person Object
Managing Contacts in the Web Storage System or Active Directory
Business Information Properties That Can Be Set and Retrieved Programmatically
Properties and Saving the Contact to Web Storage System or Active Directory
The Person object defines methods and properties for managing contact items
in the Web Storage System or Active Directory Contacts that exist in Active Directory can be saved to the Web Storage System and, conversely, from the Web Storage System to Active Directory CDO maps the information between ADSI and a schema in the Web Storage System
The Person object supports an IPerson interface that contains a comprehensive
set of personal and business information properties that can be
programmatically set and retrieved The IPerson interface contains a Fields property that provides access to the ADO Fields collection of contact-related
schema fields These fields provide additional settings, such as BusinessHomePage, that are not available as CDO properties
Person Object Properties
The following table lists the frequently used properties of the Person object
Property Description Company Contains the company name of the person contact
Configuration A reference to a Configuration object that defines the
configuration information used by the object
Email Contains the primary e-mail address of the person contact
Fields Returns the ADO Fields object for the person contact
FileAs Defines how to display the person contact
FirstName Contains the first name of the person contact
HomePhone Contains the home telephone number for the person contact
LastName Contains the last name of the person contact
MailingAddress Contains the postal mailing address for the person contact
Title Contains the job title for the person contact
WorkPhone Contains the work telephone number for the person contact
Topic Objective
To describe the
Person object
Lead-in
The Person object defines
methods and properties for
managing contact items in
the Web Storage System or
Active Directory
Discuss the Person object
and how to use it to manage
Contacts in the Web
Storage System or users in
Active Directory Discuss
each property listed in the
table in the student notes,
and then explain the
code example
Trang 32Creating a Contact by Using the Person Object
Creating a contact involves setting informational properties and saving the contact to the Web Storage System The following VBScript code uses an OLE
DB Provider for Exchange URL to create a contact
Dim objPerson, conn, strContactURL Set objPerson = CreateObject ("CDO.Person") Set conn = CreateObject ("ADODB.Connection") objPerson.FirstName = "Paul"
conn.Open strContactURL 'Save the contact to the Web Storage System objPerson.DataSource.SaveTo strContactURL, conn Response.Write "You have successfully entered " &
objPerson.firstname 'the next line of code refers to the HomePostalAddress 'property which concatenates all the postal information ' '(street, city, state, zip)
Response.Write " Who lives at: " & objPerson.HomePostalAddress
Trang 33Searching and Displaying Contacts by Using CDO and ADO
Exchange 2000
CDO
ADO
Recordset Binds
Candidates from New York
Candidates from New York
Contacts
Query
By using ADO, you can search a Contact folder in the Web Storage System for contacts with specific properties For example, a recruiter may want to search a Contact folder for candidates who live in New York State
The following example shows how to use ADO to search for candidates who live in New York and then how it binds each candidate that is returned from the
query to a CDO Person object
Dim Rs, objPerson, Conn, strContactsURL strContactsURL = _
"http://servername/exchange/administrator/Contacts/"
Set Conn = CreateObject("ADODB.Connection") Conn.Provider = "ExOLEDB.DataSource"
Conn.Open strContactsURL Set Rs = CreateObject("ADODB.Recordset") 'create a query that selects the location, display and 'email address from the Contacts file where State = NY strSQL = "SELECT ""DAV:href"" FROM "
strSQL = strSQL & """" & strContactsURL & """ "
strSQL = strSQL & "WHERE ""urn:schemas:contacts:st""" & _
"='NY'"
Rs.Open strSQL, Conn Set objPerson = CreateObject("CDO.Person")
Do Until Rs.EOF objPerson.DataSource.Open Rs.Fields("DAV:href") Response.Write objPerson.FirstName & " lives in New York" Rs.MoveNext
By using ADO, you can
search a Contact folder for
contacts with specific
properties in the Web
Storage System or the
Active Directory
Delivery Tip
Use the illustration in the
slide to discuss how ADO
and CDO are used together
Discuss the code and
explain each line
Trang 34Importing and Exporting vCards
Exchange 2000 supports the Internet industry vCard standard for obtaining
contact information through the CDO Person object You can import and
export contact information from any vCard-compliant contact application
The GetVCardStream method of the Person object returns contact information in an ADO Stream object You can use the SaveToFile method of the GetVCardStream method to export data from a Person object and the
LoadFromFile method to import vCard information into a Person object
The following VBScript code retrieves a contact from the administrator’s Contact folder and exports the values as a vCard
Dim objPerson, conn, strContactURL Set conn = CreateObject("ADODB.Connection") Set objPerson = CreateObject("CDO.Person") strContactURL = _
"http://servername/exchange/administrator/" & _
"contacts/paul west.eml"
conn.Provider = "ExOLEDB.DataSource"
conn.Open strContactURL objPerson.DataSource.Open strContact, conn 'you can use the ADO Stream object to access a vCard stream Set strm = objPerson.GetVCardStream
'Save the stream to a file strm.SaveToFile "c:\vcard.vcf", adSaveCreateOverWrite 'Alternatively, use the SaveToFile method
'directly, you don't have to use an ADO Stream object objPerson.GetVCardStream.SaveToFile "c:\vcard.vcf", _ adSaveCreateOverWrite
Topic Objective
To show how to export and
import contact information
by using the vCard format
Lead-in
You can import and export
contact information by using
the Person object from any
vCard-compliant contact
application
Explain that a vCard is a
standardized Internet
content type used to
describe attributes of people
(contacts) Discuss the code
example and explain each
line Discuss the two
methods used in the
example to create a vCard
Trang 35# Adding Calendar Functionality
Use calendar functions to create and maintain appointments and meetings You can store appointments and meetings in calendars, which are folders in the Web
Storage System An appointment represents an activity that takes place on a particular date and at a specific time A meeting is an appointment that involves
more than one individual
You can use calendar functions with Exchange 2000 to:
! Create single or recurring appointments
! Send requests to others to invite them to a meeting
! Check people's schedules for free or busy time
! Schedule the use of conference rooms and other resources
Exchange 2000 provides a calendar for each account You can also place appointments and meetings in public folders for group calendars
You can use calendar
functions with Exchange
2000 to create single or
recurring appointments,
meeting requests, and
personal and group
scheduling
Trang 36The Appointment Object
Personal Appointment or Schedule a New Meeting with Multiple Attendees
Calendar File or to a Shared Calendar File on Public Folders
Appointment
The Appointment object represents appointments and meetings You use the
Appointment object to create a new personal appointment or to schedule a new
meeting with multiple attendees When you create appointments and meetings, you can save them to a personal Calendar file or to a shared Calendar file in a public folder that all users can access
Appointment objects can have attachments Each attachment is a BodyPart
object in the appointment's Attachments collection You can easily append attachments to, or extract attachments from Appointment objects
The following table lists the frequently used properties of the
Appointment object
Property Description Attendees Returns the IAttendees interface on the implementing object
Contact Contains a person's name as a contact for an appointment
Duration Contains the duration of an appointment in seconds Either
Duration or an EndTime is required
EndTime Contains the time an appointment ends Either an EndTime
or Duration is required
Location Contains an appointment's meeting location
MeetingStatus Contains the status of an appointment: Tentative, Confirmed,
or Canceled
RecurrencePatterns Returns an IRecurrencePatterns collection of recurring
information for a recurring appointment
Sensitivity Contains the status of an appointment's sensitivity:
Company-Confidential, Personal, or Private
StartTime Contains the starting time for an appointment StartTime is a
You use the Appointment
object to create a new
appointment or schedule
a meeting
Discuss the Appointment
object and review each
property listed in the table in
the student notes