Title: Developing Web Applications With Microsoft Exchange
1Developing Web Applications With Microsoft
ExchangeTom Rizzo ? thomriz_at_microsoft.com
2(No Transcript)
3Objectives
- Understand the tools available for collaborative
development - Understand the infrastructure requirements for
web-based apps - Learn how to build collaborative applications
using Exchange/Outlook/IIS - Demos, Demos, Demos, Code, Code, Code
4The three Ts
- Technologies
- OWA
- CDO/COM Components
- Outlook HTML Form Converter
- Routing/Workflow
- Directory Integration
- Tools
- Outlook
- VID/FrontPage
- Techniques
5Demo Some Web Apps
- Job Candidates
- Helpdesk
- Calendar of Events
- News
- Expense Reporting
- Project Management
- Directory Management
6Technologies OWA
- Outlook Web Access is your best tool
- Code examples, best practices
- Steal portions for your own applications
- Provides both anonymous and authenticated access
7Architecture
Browser
Exchange Server
Internet Information Server
Active Server Pages
CDO CDOHTML
Lang
Upload
OWAScripts
8Architecture
- Script Directory Structure
Global.asa
exchsrvr\webdata
USA
FRN
JPN
constant.inc
forms
finduser
calendar
contacts
inbox
help
images
lib
ipm
report
ipnrn
ipnnrn
ndr
dr
note
post
schedule
contact
document
Custom and converted forms
9Setup/Authentication
- Setting up Exchange for your Intranet is easy,
depending on your authentication needs - Two types of authentication
- Basic
- Clear text authentication
- Can use SSL for encryption
- All web browers support it
- NT Challenge/Response
- Encrypted
- Can use SSL for further encryption
- Requires IE
10Setup/Authentication
- Depending on authentication, machine
configuration varies - Basic
- Exchange Server and IIS can be on separate
machines or same machine. - NT Challenge/Response
- Exchange Server and IIS are required to be on the
same machine. Windows 2000 will support separate
machines. - You may be wondering why this is necessary. . . .
. .
11Anonymous Web pages
NT Server (separate or same machine)
Web Browser
IIS Server
1
2
3
Browser connects to IIS by requesting a web page.
IIS automatically is logged on as
IUSR_MachineName account.
The IUSR_MachineName account is used to retrieve
web page.
12Basic Authentication
Web Browser
IIS Server
NT Server (separate or same machine)
1
2
3
Browser connects to IIS by requesting a web page.
IIS automatically is logged on as
IUSR_MachineName account.
The NT Account specified is used to retrieve web
page.
13NTLM Authentication
Web Browser
IIS Server
NT Server (must be same machine)
You cannot proxy the authentication
1
2
3
Browser connects to IIS by requesting a web page.
IIS automatically is logged on as
IUSR_MachineName account.
The NT Account specified is used to retrieve web
page.
14How authentication works
- For Basic or NTLM
- IIS is always initially logged in as
IUSR_MACHINENAME - This account has no permissions to your Exchange
Server accounts by default - If you do not change this authentication in your
application, you will get either a Logon failed
error or a FailOneProvider error
15Changing permissions
- In order for secure access, your application
needs to check the server variables to see if the
client is authenticated - If not, your application needs to send back 401
Unauthorized - This will prompt the browser to force
authentication - For NTLM, no screen appears
- For Basic, username/password logon appears
16From Outlook Web Access
Public Function BAuthenticateUser On Error
Resume Next BAuthenticateUser False
bstrAT Request.ServerVariables("AUTH_TYPE")
If InStr(1, bstrAuthTypesAccepted, bstrAT,
vbTextCompare) lt 2 Then Response.Buffer
TRUE Response.Status ("401
Unauthorized") Response.End Else
BAuthenticateUser True End If End
17CDO Object Model
Session
Inbox
Address lists
Outbox
AddressEntries
InfoStores
Fields
RootFolder
AddressEntryFilter
Messages
Fields
MessageFilter
Fields
Fields
Folders
18CDO Rendering Objects
RenderingApplication
There are two classes of view objects -
TableView - CalendarView
19Code Walkthrough
- Lets a look at the code for all of them!
20Outlook HTML Form Conv.
- Provides conversion between Outlook Forms and
ASP - Shipped with SP1/SP2
- Works with Netscape and Internet Explorer
21Client System Requirements
- Outlook 8.03, Outlook 98/2000
- Used by the converter to obtain custom fields off
the forms - FM20.DLL
- Used to access form descriptions
- Windows 95 or Windows NT Workstation/Server
- You do not need to run the converter on the
Exchange Server
22Server Requirements
- IIS 3.0 with ASP 1.0b or IIS 4.0
- Outlook Web Access installed
- Share out the webdata directory under the
Exchange directory. - Eg. C\exchsrv\webdata
23Whats Supported?
- Forms can be converted from a number of places
- Outlook template files (OFT files)
- Organizational Forms Registry
- Folder Forms Registry
- Personal Forms Registry
- Multiple forms can be converted at once
24How Do I Find The Form?
- Copied to the OWA directory structure
25Folder Names
- Netscape does not support folders that have
spaces in the name - Eg. IPM.Post.While you were out
- This will try to create a folder under the
IPM/Post directory tree named While you were out - The Form Converter automatically converts spaces
to 20 so Netscape can access the forms
26Architecture Of Conversion
- Components
- Wizard
- OFT-HTML Converter
- Templates
- Template Processor
- Installshield setup
27Conversion Details
- Frmroot.asp
- Entry point into the form
- Includes script and HTML frameset that houses the
rest of the components - Three Frames
- Title.asp - Title page
- PageN.asp - swapped into frame by title.asp where
N is the page - commands.asp - hidden commands
28Movement Between Tabs
- Data is submitted to command.asp and copied into
the cached message object on the IIS server - Data is retrieved for the new page from the
message object - The new page is swapped into the frameset and
sent to the browser
29Commands.asp
- Hidden form
- Detects custom and built-in field values when
pages are submitted to the web server - The on_send, on_reply, on_replyall, on_save,
on_forward as well as custom action handlers are
implemented here
30Form.ini
- Contains one section called Description
- Has friendly name of form and whether it is a
hidden form - OWA dynamically generates list of custom forms
based on form.ini
Description DisplayNameProject Management
Application Hidden0
31Whats Supported?
- Certain types of forms are supported
- IPM.Note - Mail Message
- IPM.Post - Post Form
- IPM.Contact - Contact Form
- Task and Appointment forms are not supported
- Work around to get UI converted, copy controls to
a supported form type - Forms must have their own message class - cannot
be named default Outlook forms - e.g.,
IPM.Contact
32To-Dos
- To-dos are generated if the form encounters
certain conditions - To-dos are displayed at the end of the
conversion and also saved with the form in its
OWA folder
33Whats supported?
- Most Outlook controls are supported
- Label, textbox, combobox , listbox, checkbox,
optionbutton, frame, commandbutton, multipage,
and image control - Some controls are limited in conversion due to
HTML limitations - Image controls are converted to gifs
- Initial values, required fields, datatype
validation, separate read and compose forms,
hidden controls and pages are all supported
34Advanced Services
- Routing/Workflow
- Directory integration and management
- Full-text Indexing and Search
- Look at my session from Sunday
35Routing/Workflow
- Exchange 5.5 included the Event Scripting Agent
- Exchange 5.5 SP1 included the Routing Objects
technology - Both technologies have object models that you can
program against
36Architecture Overview
Visual Interdev 1.0 Visual Interdev 98
Outlook 97 8.03 Outlook 98
Event sinks
Intrinsic Objects EventDetails.Session EventDetai
ls.MessageID EventDetails.FolderID CDO Session
uses mailbox identity of last script author
Custom Handlers
Script agent (scripto.dll)
Java
Visual Basic/C
Script sink (ss.dll)
EVENTS.EXE
NT Service
Exchange Server store
Event source
37Event Architecture
Event service
Exchange store
Notify
Application folder
Change list
Docs
ICS
Event handler (agent)
- ICS (Incremental Change Synchronization)
- Events not missed, even if server is offline
- New, changed, deleted, scheduled event (timer)
38Exchange Routing Objects
RouteDetails
ProcInstance
Map
Row
Log
Participant
VoteTable
WorkItem
39Exchange Routing Engine
- Requires Exchange 5.5 SP1
- Implemented as Custom Handler on top of Event
Service - Uses OnMessage_Created event to create Process
Instance - Each Process Instance Message (PIM) executes its
defined Map - Process Map controls routing execution by
invoking actions
40Creating A Process Instance
Folder
Agent Binding Message (Hidden)
Folder Script
New Item
Default Folder Map
Map
Item
Map
Map
Map
Item
Item
Item
New Process Instance
Existing Process Instances
41Process Definition Map
- Default map stored in folder
- Copied onto new process instance messages
- OnNew and OnTimer folder events update state
42Hub And Spoke Topology
Logical Route View
A
B
C
Startgt
Physical Route View
Hub sends item to A
A
who advances route by
User instantiates
replying to hub
process
Startgt
by submitting item to
hub folder
Hub containing
Process
Definition
Hub sends item to C
C completes process by
replying to hub
Hub sends item to B
B
C
who advances route by
replying to hub
43Some Demos. . .
- Custom Routing Applications
- Deployment Tools
- Lets look at the code!
44COM Components
- 3 New COM Components
- ACL
- Rule
- AcctCrt
- Wrap the most common requested features
- Part of the Platform SDK (PDC Version or posted
to msdn.microsoft.com)
45Directory Integration And Management
- For Collab apps, the directory is a key
component - Find people, resources
- Dynamically resolve roles
- Store custom attributes
- Store organizational information
- ADSI is the key object model to use to access
directory information in Exchange
46Some Demos. . .
- Directory management
- Querying the directory
- Lets look at the code!
47What Resources Are Available?
- Exchange Developers Forum
- http//www.microsoft.com/exchange/developers
- Exchange appfarm
- http//www.microsoft.com/exchange/appfarm
- Platform SDK (includes EDK)
- http//msdn.microsoft.com
48Resources
- CDO Community resources
- www.slipstick.com
- www.cdolive.com
- www.outlookexchange.com
- Exchange Listserver
- OWA Deployment / Troubleshooting
- New whitepaper and KB article Q125329
- support.microsoft.com/support/exchange/content/whi
tepapers/owa_tshoot.asp
49Resources
50Tip 1Avoid the authentication trapFailed to
get inbox message
- Make sure to implement authentication correctly
- Remember NTLM means same machine
- When creating CDO apps, IIS is running under the
context of IUSER_MACHINENAME, you need to force
the browser to authenticate
51Tip 2Use early binding in Visual Basic
- Better compile time syntax checking
- Generates faster code
- Very simple to do
' Late bound Dim objSession As Object Dim
objNewsgroup As Object Dim objPostItem As Object
Early bound Dim objSession As MAPI.Session Dim
objNewsgroup As Folder Dim objPostItem As Message
52Tip 3Avoid the GetNext trap
- Temporary collection objects always point to
first item - Create intermediary objects
' error collection returns the same message both
times MsgBox("first message "
inboxObj.Messages.GetFirst.Subject) MsgBox("next
message " inboxObj.Messages.GetNext.Subject)
objMessages inboxObj.Messages MsgBox("first
message " objMessages.GetFirst.Subject)
MsgBox("next message " objMessages.GetNext.Sub
ject)
53Tip 4Use with statements
- Object creation is expensive
- Internal object created for each period that
appears in the statement - Reuse objects whenever possible
' warning do not code this way this is
inefficient MsgBox "Text "
objSession.Inbox.Messages.GetFirst.Text MsgBox
"Subj " objSession.Inbox.Messages.GetFirst.Subj
ect
With objSession.Inbox.Messages.GetFirst
MsgBox "Text " .Text MsgBox "Subj "
.Subject End With
54Tip 5Accessing the root public folder
Set objInfoStores objSession.InfoStores For i
1 To objInfoStores.Count If objInfoStores.Item(
i) "Public Folders" Then Set
objInfoStoreobjInfoStores.Item(i) Exit
For End If Next bstrPublicRootID
objInfoStore.Fields.Item( _ H66310102
).Value 'PR_IPM_PUBLIC_FOLDERS_ENTRYID Set
objTopFolder objSession.GetFolder _
(bstrPublicRootID,objInfoStore.ID)
55Tip 6Deferred sending and delivery
- Deferred sending
- Message waits in users outbox
- Property H3FEF0040
- Deferred delivery
- Message waits in MTA queue
- Property H000F0040
WITH objMessage.Fields .Add H3FEF0040,
CDate(6/1/98 30000 AM") .Add HF0040,
CDATE(6/1/98 120000 PM) END WITH
56Tip 7Checking Access Rights
- PR_ACCESS (H0FF40003)
- Applies to folders and messages
Dim folderAccess as Long Dim canReadItems,
canCreateItems, canDeleteFolder, _
canModifyFolder, canCreateFolders as
Boolean ... folderAccess objFolder.Fields
(H0FF40003) canReadItems folderAccess AND
H00000002 canCreateItems folderAccess AND
H00000010 canDeleteFolder folderAccess AND
H00000004 canModifyFolder folderAccess AND
H00000001 canCreateSubFolders folderAccess AND
H00000008
57Tip 8Making outlook views accessible to the Web
- Only applies to table views
- In Outlook, edit folder properties
- Set Automatically Generate Microsoft Exchange
Views - Refresh ContainerRenderer objects view collection
58Tip 9Filtering appointments by date
- CdoPR_START_DATE (H00600040)CdoPR_END_DATE
(H00610040)
Set objCalendarFolder objSession.GetDefaultFolde
r _ (CdoDefaultFolderCalendar) Set
objAppointments objCalendarFolder.Messages Set
objAppointmentFilter objAppointments.Filter WITH
objMessageFilter.Fields .Add
CdoPR_START_DATE,CDate("12/18/98 50000 PM")
.Add CdoPR_END_DATE,CDate("12/18/98 90000
AM") END WITH
59Tip 10Retrieving a users proxy addresses
Set objRecip objMessage.Recipients(1) Debug.Prin
t "Display Name " objRecip.Name Debug.Print
"Default Address " objRecip.Address Set
objAddrEntry objRecip.AddressEntry Set objField
AddressEntry.Fields(H800F101E)
'PR_EMS_AB_PROXY_ADDRESSES For Each v In
objField.Value Debug.Print "Foreign System
Address " v Next v
60Tip 11Setting the from field on posted items
- Useful for anonymous postings
WITH objMessage.Fields .Add CdoPR_SENT_REPRESENTI
NG_NAME, John Doe) H0042001F .Add
CdoPR_SENT_REPRESENTING_ADDRTYPE,
SMTP) H0064001F .Add CdoPR_SENT_REPRESENTING
_EMAIL_ADDRESS, _ JDoe_at_company.com) H0065
001F END WITH
61Tip 12Accessing direct reports in the directory
- Reports stored in multi-valued string
- PR_EMS_AB_REPORTS_T (H800E101E)
- See org. chart example on App farm
Dim objManager, objPerson as MAPI.AddressEntry Dim
objDirectReports as OrgChart.Reports Set
objDirectReports CreateObject("OrgChart.Reports"
) Set objDirectReports.DataSource myManager For
idx 1 to objDirectReports.Count set
objPerson objSession.GetAddressEntry _
(objDirectReports.Item(idx)) Debug.Print
objPerson.Name Next
62Tip 14Setting reply-to
- Example only supports one recipient
- Reply-to names (H0050001E)
- Reply-to EntryIDs (H004F0102)
Function SetReplyTo (objMessage as MAPI.Message,
_ objReplyToMe As MAPI.AddressEntry) Di
m entryblob, lengthStr, flatEntry As
String lengthStr CStr(Hex(Len(objReplyToMe.ID)/
2)) flatEntry lengthStr "000000"
objReplyToMe.ID structLength Hex(Len(flatEntry)
/ 2) entryblob "01000000" structLength
"000000" flatEntry objMessage.Fields.Ad
d H0050001E, objReplyToMe.Name objMessage.Fields.
Add H004F0102, entryblob
63Questions?
64(No Transcript)