By Scott
Mauvais
With the release of Microsoft Exchange
Server 2000, Microsoft� has created a true development platform for
designing messaging and collaboration applications. Exchange, a
development platform? If you are like most developers, you have probably
viewed Microsoft Exchange as more of an infrastructure product than as a
development platform. Sure, you could always build input forms with
Exchange Forms, but Exchange is more about mail and schedules than
application development, right? Of course not.
While it has always been a great development environment, Microsoft
Exchange Server has been overshadowed by Microsoft SQL Server� and the
Microsoft Visual Studio� tools when developers thought about creating
applications. With the release of Microsoft Exchange Server 2000, this all
changes. Microsoft Exchange Server (originally left off the Windows� DNA
platform) not only is a full member of the .NET Enterprise Server
family, but also is the first Microsoft product that sports the new
developer-friendly Web Storage System.
In this month's article, I
will give you a brief tour of the Microsoft Exchange Server 2000
development environment and show you how the Web Storage System will
change the way you think about storing data. Next I will give you a hint
of some of the things you can expect from the Web Storage System when
Microsoft Microsoft� SharePoint�Portal Server ships (previously
code-named "Tahoe"). For great tips on handling Exchange 2000 Server
disaster recovery, see Ian Matthews's IT feature this month, Exchange 2000 Server
Disaster Recovery: Worst-Case Survival Handbook.
I will conclude with a list of references with which you can learn more
about developing collaborative applications for Microsoft Exchange
Server 2000 in general and the Web Storage System in particular. The
most comprehensive source available is a new book from Microsoft Press
called Programming
Collaborative Web Applications with Microsoft Exchange 2000 Server by
Mindy Martin. My goal in this article is to give you a brief overview of
some of the technology and get you oriented as you dive into Exchange
development. If you really want (or need) to ramp up quickly, you should
get Mindy's book.
The Exchange Development
Environment
If you have never developed for Exchange, you can look
at this development environment as taking the best from database, Web, and
collaboration toolsets and rolling them all together in a single server
product.
The first thing to notice about this release is that
Microsoft has fully integrated the Active Directory� into the Exchange
Server product. This not only adds value to your hard-won ADSI programming
skills, but also greatly simplifies account management. In the Microsoft
Windows NT� 4.0 and Microsoft Exchange Server 5.5 world, you needed to
update both the Exchange Directory and the NT SAM if you wanted to create
a new user or change some attributes about him or her. Updates became even
more complicated when you wanted to schedule a meeting and needed to check
a user's free/busy status first. Just imagine what this was like in a
multimaster domain model with several Exchange servers spread out on
different sites.
With each new release, Microsoft Exchange Server
supports more and more communication protocols. In the current release,
almost every collaboration-related protocol you can think of is included:
HTTP, WebDAV, SMTP, NNTP, IMAP, POP, LDAP, and our old friend MAPI. So no
matter what system you need to connect to, Microsoft Exchange Server 2000
probably can connect to it.
The Web Storage
System
On top of this, you gain access to Microsoft's new,
super-cool Web Storage System. If you have not read up on the Web Storage
System, I highly recommend you check out Sean McCormick's article in the
July 2000 issue of MSDN Magazine entitled Exchange
2000: Web Storage System, Workflow Tools, and CDO Turbocharge
Collaboration Apps.
The Web Storage System is similar to the
information store in earlier versions of Microsoft Exchange Server. Like
the information store, the Web Storage System is broken down into public
stores and private, mailbox stores. Now rather than being built on top of
databases based on a variant of the JET engine, the stores in Microsoft
Exchange Server 2000 are built on the Web Storage System. The Web Storage
System is hierarchical in nature, being made up of folders that contain
either items or subfolders. Conceptually, it is like the typical file
system with directories, files, and subdirectories.
The Web Storage
System's real power comes from the types of data it can store and the ways
in which you can access the data. Not only can the Web Storage System keep
almost every type of data you can imagine, such as traditional Exchange
items (mail message, contacts, calendar items, Tasks, and so on), but also
it can hold media files, office documents, and ASP files, just to name a
few. In addition to simply storing the data, the Web Storage System
integrates the content with the associated metadata.
Because the
Web Storage System holds all sorts of documents, this metadata can cover
the gamut from obvious things such as name of the item, its size, and its
last update time to resource-specific properties such as author, word
count, and total edit time for a Microsoft Word document. You can even
include custom properties that you have designed specifically for your
application. The Web Storage System then lets you search across all these
properties and marry a property-based search with a full text search of
the content. In short, you can look at it as the object file system of the
Cairo vision. Note that Cairo never shipped. It was originally the
code-name for the release of Windows NT after version 3.5x, but priorities
changed and Windows NT 4.0 shipped instead. Most of the Cairo feature set
made it into Windows 2000.
After you have stored all this disparate
data, you probably want to retrieve it somehow. You can retrieve data from
the Web Storage System using whichever access method you like best. If you
are a database programmer, you might choose ActiveX Data Objects (ADO).
Microsoft Exchange Server 2000 installs a new OLEDB provider named ExOLEDB
that extends OLEDB in much the same way that OLEDB for OLAP extended the
original OLEDB to provide access to multidimensional data stores. In this
case, ExOLEDB provides native access to the folders, items, and files in
the Web Storage System. Conversely, if you are an old-time exchange
developer, you might gravitate toward the Collaborative Data Objects (CDO)
model. Interestingly, CDO has been rewritten and now sits on top of
ExOLEDB. Finally, if you are a Web developer, you might feel more
comfortable with the open Web Distributed Authoring and Versioning
(WebDAV) protocol. While each method has its strengths (for example,
querying and navigating for ADO and sending messages for CDO), you will
find a great deal of overlap among access methods so that you can choose
the one you like best.
As an example, imagine you wanted to query
the Web Storage System for all items with a specific property value across
all types of items. Remember from our discussion earlier that the Web
Storage System integrates content with the metadata so that you have great
flexibility in your search criteria. To give you an idea of how you go
about doing this, I have included some code from the sample application in
Mindy Martin's Programming
Collaborative Web Applications with Microsoft Exchange 2000 Server.
Her sample application is a zoo management system, and this snippet
demonstrates how you would use ADO to locate all the items that referred
to the �Divine Roostrus� species.
Listing 1.1: Query a Web
Storage System for All Resources with a Specific Custom Property
Value
Sub SearchForCustomProperty()
' Look
through all of the folders
' in a Web Storage
System
' for resources with a specific
' custom
property value.
Dim cnn As
ADODB.Connection
Dim rst As ADODB.Recordset
Dim
urlQueryFld As String
Dim strSQL As String
' Build the URL string
urlQueryFld = file://./backofficestorage/domain.com/
_
& "Applications/Zoo
Management/"
' Open a connection to the
Applications WSS
Set cnn = New ADODB.Connection
With cnn
.Provider =
"exoledb.datasource"
.Open
urlQueryFld
End With
' Build
the SQL statement
strSQL = _
"SELECT " & AddQuotes("DAV:displayname") &
_
", " &
AddQuotes("DAV:href")
strSQL = strSQL &
_
" FROM SCOPE('deep traversal of " &
_
AddQuotes(urlQueryFld) &
"')"
strSQL = strSQL & _
"
WHERE " & _
AddQuotes("zoomgt:species")
& "= 'Divine Roostrus'"
strSQL = strSQL &
_
" ORDER BY " &
AddQuotes("DAV:displayname") & " DESC"
Set
rst = New Recordset
With rst
.Open strSQL, cnn
End With
'
Return the names of the resources and their URLs
Do Until
rst.EOF
Debug.Print
_
rst.Fields("DAV:displayname"),
rst.Fields("DAV:href")
rst.MoveNext
Loop
rst.Close
cnn.Close
Set cnn =
Nothing
Set rst = Nothing
End Sub
I have covered only the most basic aspects of the Web Storage System.
To get a thorough understanding of the Web Storage System and how you can
build your Web applications around it, read Chapter 2 of Mindy Martin's Programming
Collaborative Web Applications with Microsoft Exchange 2000 Server.
Actually, I recommend that you read the entire book because the whole
thing is full of essential (and hard to find) information about the
architecture and schema of the Web Storage System. I expect this to become
one of the must-read books for the Web Storage System just as David
Chappell's Understanding
ActiveX and OLE is a must-read for COM developers.
Microsoft SharePoint Portal
Server
Once you have come up to speed on the Web Storage
System, you will be ready for Microsoft's upcoming document management and
corporate portal product Microsoft SharePoint Portal Server,
previously code-named "Tahoe."
While Microsoft Exchange Server
2000 serves as a collaboration platform, SharePoint Portal Server focuses
on helping companies manage the information their workers have
(collaboratively) produced. Because these tasks are so closely related,
the products themselves fit together quite well. From a technology
standpoint, both are built on top of the Web Storage Engine. Therefore,
when developing applications for Tahoe, you will leverage the same
Exchange development skills�ADO, XMLHTTP, and WebDAV�you learned in Mindy
Martin's Programming
Collaborative Web Applications with Microsoft Exchange 2000 Server.
Microsoft SharePoint Portal Server has a large list of features,
but to make things easy (and to make sure I save some space to walk
through some sample code!) I will group them together into two large
categories: document management and context indexing and
search.
Document Management
Microsoft
SharePoint Portal Server provides a means of versioning documents and
routing them for approval. It builds upon the Web discussion features in
Microsoft Office 2000 that allows reviewers and coworkers to add comments
to document without affecting the content of the document
itself.
Typically, most users will access document management in
SharePoint Portal Server via the SharePoint Portal Server Portal
that is based on Microsoft
Digital Dashboard technology, through Microsoft Office, or through
extensions to Microsoft Windows Explorer. However, SharePoint Portal
Server also provides COM interfaces to all the underlying objects and
functions so that you will be able to develop very robust
applications.
Better yet, the SharePoint Portal Server Portal is
built with Web Parts and stored in the Web Storage System. Web Parts are
chunks of XML and HTML and are script-packaged according to a common
specification. Because Microsoft has created a standard Web Parts schema,
any application that can consume Web-based content can easily be extended
to use (and reuse) Web Parts. As you might expect, you can access Web
Parts through WebDAV as well as Microsoft Exchange Server 2000. To speed
up your development of Web Parts, Microsoft has created an add-in for
Microsoft Visual InterDev�, which you can download as part of the Digital
Dashboard Resource Kit (DDRK) 2.01.
Content Indexing and
Search
Microsoft SharePoint Portal Server provides full-text
indexing based on a SQL-like syntax. To acquire the data in the first
place, the search engine itself will crawl several different content
stores including SharePoint Portal Server-based Web sites, external Web
sites, the Web Storage System, network and local file shares, Microsoft
SQL Server databases, and of course Microsoft Exchange stores.
To
create applications that use this rich functionality, you simply use the
same development tools and approaches you use to build Exchange
applications: ADO, XMLHTTP, and WebDAV.
To learn more about
SharePoint Portal Server, see the SharePoint
Portal Server Home Page. Once there, you will find many resources
including white papers, several guides, an evaluation
edition, and, at the time of this writing, Beta 2 of the
SDK.
Now that you have an idea of what the Web Storage System can
do, let's take a look at how you can use it in your
applications.
Building a Simple Inbox with
WebDAV
In this section, I will show you how to create a very simple
WebDAV application that will list the items in your Inbox or any other
folder in Microsoft Exchange Server 2000. The purpose here is not to
develop fully functional sample code. Rather, I hope to give you a flavor
of the development methodology and give you a head start as you learn to
develop Web-based applications on Microsoft Exchange Server
2000.
Building this application requires only four steps:
- Open a connection to a Microsoft Exchange 2000 Server.
- Build a WebDAV XML document that describes the resource you want. In
this example, the resource is the list of items in my Inbox.
- Connect to a Microsoft Exchange Server 2000, and send this WebDAV
XML document.
- Retrieve the result into an XML document, apply an XSLT to it, and
display the result
While you would normally do this procedure in
an HTML or ASP file so that you could display the results in a browser, I
will do this as a simple VBScript file because it is easier to focus on
the core logic when you don't have HTML tags getting in the way. Also, in
the code presented here, I have removed all the variable declarations and
error handling. If you want, you can download the fully commented source
code from my web
site.
The first step in connecting to the Microsoft Exchange
Server 2000 resource is pretty straightforward because the Web Storage
System provides direct URL access to every folder and item.
�-- Open an HTTP connection
to my Exchange Server
xmlHTTP.open "PROPFIND",
�http://mspress.microsoft.com/developer/feature/�, _
False,
_
�scott�, _
�secret�
I simply call the open
method of the Microsoft.xmlHTTP object and pass in the WebDAV command
PROPFIND, the URL to my server, a flag for whether I want an asynchronous
connection, and finally my credentials. A discussion of the WebDAV
commands is out of the scope of this article, but you can find a list of
them under WebDAV
Protocol Commands on MSDN.
Next, I build the WebDAV document:
'-- Build an XML document to
sDAV = "<?xml
version='1.0'?>"
sDAV = sDAV & "<d:propfind
xmlns:d='DAV:'>"
sDAV = sDAV &
"<d:prop><d:displayname/></d:prop>"
sDAV =
sDAV & "<d:prop><d:contentclass/></d:prop>"
sDAV
= sDAV & "<d:prop><d:iscollection/></d:prop
sDAV = sDAV
& "</d:propfind>"
Here I am telling the Microsoft Exchange Server 2000 that I want it to
return three properties: the display name, content class (document type),
and whether the item is a collection (folder). As with the WebDAV
commands, the WebDAV schema is out of scope. You can find out more about
the schema from DAV:Namespace,
also on MSDN.
Now that I have the command ready, I need to set a
few HTTP headers and send the WebDAV document to the server:
'-- Set my mime
type
xmlHTTP.setRequestHeader "Content-type:", "text/xml"
'-- Set DAV header for search depth
xmlHTTP.setRequestHeader "Depth",
"1"
'-- Send request
wscript.echo "Sending request."
xmlHTTP.send
(sDAV)
Because I indicated I wanted
an asynchronous connection (something one would usually not do in
production) the send method call blocks until the server sends back the
complete response. Once the call returns, I have my data and I am ready to
load the response into an XML document, transform it with a simple XSLT,
and output the result.
'--
Load result into DOM
xmlDoc.loadXML (xmlHTTP.responseText)
'-- Load result
into DOM
xmlDoc.loadXML (xmlHTTP.responseText)
'-- Load my XSLT
xslMailList.Load ("MailView.xsl")
'-- Output the result
wscript.echo "<h1><center>Inbox for "
& USERID & "</h1></center>"
wscript.echo
xmlDoc.transformNode(xslMailList)
While I won't walk
through it, the download file contains the XLST used to transform the XML
returned from Microsoft Exchange Server 2000.
As I mentioned
earlier, you would normally run this type of application in a browser. If
I had, the result would have looked like Figure 1.
Figure 1:
Simple Inbox Built with WebDAV.

Conclusion
As we have
seen, Exchange provides a robust platform for developing collaborative and
messaged-based applications. In this month's article, I started off with
an overview of Microsoft Exchange Server 2000 from a developer's
perspective. Next we moved on to a discussion of the new (super cool) Web
Storage System, and I showed you how you can use it to store many
different types of data. From there, I gave you a brief introduction to
Microsoft SharePoint Portal Server and showed you how you would be able to
reuse your Exchange Server and Web Storage System development skill to
create information management applications. Finally, I concluded with a
walk-through of some sample code that uses WebDAV and XSLT to connect to a
Microsoft Exchange Server 2000 via HTTP and display the contents of a
folder.
Microsoft Press Solutions
The best way
for a developer to get the most out Exchange is to pick up a copy Mindy
Martin's Programming
Collaborative Web Applications with Microsoft Exchange 2000 Server.
Other titles from Microsoft Press you might want to check out include the
following:
- Programming
Microsoft Outlook and Microsoft Exchange, Second Edition �Develop
and run business services with detailed guidance on using Microsoft
Outlook� 2000, Exchange 2000, and Exchange 5.5.
- Introducing
Microsoft Exchange 2000 Server �This exclusive preview gets you
ahead of the rest and delivers an authoritative technical overview of
the fundamental design improvements in Exchange 2000.
- Developing XML
Solutions� connects XML to your enterprise systems: it shows you how
to interface XML with databases and work with the latest XML-related
technologies for data interchange
- XML Step
by Step� gives you all the basics of XML programming: what XML is
(and isn't!), why it's important, and how to use it on the Web and with
Microsoft technologies.
- Microsoft
Exchange Server Training Kit �Follow step-by-step lessons and
hands-on lab exercises that teach you how to support and administer
Exchange Server 5.0 and Exchange Server 5.5. Useful as on-the-job
training or as a resource for the Microsoft Certified Professional (MCP)
exams.
- Microsoft
Exchange 2000 Server Resource Kit �This resource kit provides
everything you need to deploy, install, back up and restore, manage
security for, troubleshoot, and optimize Exchange. It includes more than
1,000 pages of detailed technical information, plus timesaving utilities
on CD.
Additional Microsoft Resources
- For the latest up-to-date information for Exchange developers, you
will want to visit MSDN's Exchange Developers
Center and the Exchange
Server Developer Information Site regularly.
- Digital Dashboard Resource Kit (DDRK) 2.01 � If you worked with the
DDRK 1.0 and were disappointed, you really need to take a second look at
the current release. It has been totally reworked and built around Web
Parts.
- To view presentations from Microsoft Exchange Conference 2000, visit
MEC
2000 site.
- The Exchange SDK contains several sample applications both in Visual
Basic and Visual C++.
- For detailed information about all Microsoft Press Windows 2000
titles for developers, visit the Windows 2000
for Developers page. For a complete list of all the developer
titles, see the Developer
Tools section of the Microsoft Press Web
site.