Title: CDO for Exchange 2000:Messaging
1CDO for Exchange 2000 Messaging Jason
MayansProgram ManagerExchange Server Product
UnitMicrosoft Corporation
2(No Transcript)
3CDO for Exchange 2000 Messaging Jason
MayansProgram ManagerExchange Server Product
UnitMicrosoft Corporation
4Agenda
- Introduction to MIME Messaging
- Messaging features scenarios
- Messaging Object Model
- Objects
- Interfaces
- Code Samples
5Intro to MIME Messaging
- Internet Standard
- Multiple content formats in mail
- Extends RFC 822
- Headers for encoding and identifying content
- Content-Type
- Content-Transfer-Encoding
- Content-Disposition
- Supported by Internet mail clients
6MIME Messages
- Divided into Body parts
- Separated by a boundary tag
- Body parts contain child body parts or data
- Content-Type
- Single part body parts
- Multipart body parts
7Sample MIME MessageText and HTML
From "Jason Mayans" ltjmayans_at_microsoft.comgtTo
"Bob" ltbob_at_samples.microsoft.comgtSubject Text
HTML MessageDate Sat, 4 Sep 1999 123248
0700MIME-Version 1.0Content-Type
multipart/alternative boundary"----_123" ------
_ 123Content-Type text/plain
charset"iso-8859-1Content-Transfer-Encoding
quoted-printable This is a multipart/alternative
text html message. ------_ 123Content-Type
text/html charset"iso-8859-1Content-Transfer-E
ncoding quoted-printable ltHTMLgtltBODY
bgColor3DffffffgtltFONT color3Dff0000
face3DArial size3D2gtThis is
a20multipart/alternative text amp html
message.lt/FONTgtlt/BODYgtlt/HTMLgt------_123--
8CDO Messaging Scenarios
- Server-based messaging development
- Targeted mailers
- Email notifications
- Events Store and Transport
- Discussion forums
- Any application constructing MIME content
9Messaging Objects
Message
IBodyPart IMessage IDataSource IRow
Addressee
IAddressee
BodyParts Collection
Configuration
IBodyParts
IConfiguration IRow
BodyPart
IBodyPart IRow
10MessagingFlexible design
- CDO lets you decide how much to abstract the
underlying MIME data - Use IMessage and let CDO handle the MIME details
- Use IBodyPart for more explicit control over the
MIME hierarchy - Use Streams for complete control
IMessage
IBodyPart
Streams
11IMessage InterfaceIntroduction
- Supported by messaging objects
- Shortcuts for complex MIME operations
- AddAttachment, CreateMHTMLBody,
AddRelatedBodyPart - Headers and other properties in ADO Fields
collection - Exposes an ADO Stream for access to underlying
data
12IMessage InterfaceSending and posting messages
- Messages can be sent via various transports
- SMTP
- Local and Remote
- NNTP
- Local and Remote
- Exchange Outbox
- Submit through OLE/DB directly to Outbox
- Public Folder Posting
13IMessage Interface Sending a simple message
Set Msg CreateObject(CDO.Message) Set
Msg.Configuration myConfig Msg.To
jeff_at_samples.microsoft.com Msg.Subject The
Meeting Msg.TextBody What time is the meeting
today? Msg.Send
14IMessage Interface Mail a web page with
attachment
Set Msg CreateObject(CDO.Message) Set
Msg.Configuration myConfig Msg.To
jason_at_samples.microsoft.com Msg.Subject
Todays Top Stories Msg.CreateMHTMLBody
http//www.msnbc.com/news/311517.asp Msg.AddAtta
chment D\news.txt Msg.Send
15IMessage Interface
Mail This Page To a Friend Button
16IBodyPart InterfaceOverview
- Handles MIME body parts
- Supported by all MIME-based objects
- ADO Stream access
- Full stream, de/encoded
- Collection for access to child body parts
- ADO Fields collection provides access to headers,
properties
17IBodyPartExposing the MIME hierarchy
MIME MessageContent-Type multipart/mixed
Content-Type multipart/alternative
Content-Type text/plain
Content-Type text/html
Content-Type application/msword
18IBodyPartLoading text
Content-Type multipart/alternative
Content-Type text/plain
Content-Type text/html
Set Msg CreateObject(CDO.Message) Set Bp
Msg.Bodypart Bp.ContentMediaType
multipart/alternative Set NewBp
Bp.Bodyparts.Add NewBp.ContentMediaType
text/plain Set Strm NewBp.GetDecodedContentStr
eam Strm.Type adTypeText Strm.Position
0 Strm.LoadFromFile D\plaintext.txt Strm.Flush
Set NewBp Bp.Bodyparts.Add NewBp.ContentMediaTy
pe text/html Set Strm NewBp.GetDecodedConten
tStream Strm.Type adTypeText Strm.Position
0 Strm.LoadFromFile D\htmltext.txt Strm.Flush
19MIME Body Parts
20IDataSourceOverview
- Provides access through CDO to data sources
- Open data
- Save data
- Indicates dirty state
- Allows you to manipulate content with the right
object
21IDataSourceAccessing mail from a folder
Set conn CreateObject(ADODB.Connection) Set
msg CreateObject(CDO.Message) Conn.provider
exoledb.datasource Conn.ConnectionString
file//./backofficestorage/mail.microsoft.com/pu
blic/discuss Conn.Open Set rs conn.execute
Select chr(34) DAVhref chr(34)
from scope(shallow traversal of
file//./backofficestorage/mail.microsoft.com/pub
lic/discuss) While not rs.EOF msg.DataSource.Op
en rs(DAVhref),conn msg.Attachments.DeleteAll
msg.DataSource.Save rs.MoveNext Wend
22IDataSourceEmbedded messages
RFC 822 MessageContent-Type multipart/mixed
Content-Type text/plain
Content-Type message/rfc822
Sub AppendToEmbeddedSubject(Msg,Subject) Set
EmbdMsg CreateObject(CDO.Message) For
each bp in Msg.BodyPart.BodyParts If
Bp.ContentMediaType message/rfc822
then EmbdMsg.DataSource.Open bp,
IBodyPart EmbdMsg.Subject EmbdMsg.Subject
Subject EmbdMsg.DataSource.Save End
If Next End Sub
23ConfigurationPurpose
- Specifies user options
- Display name
- server configuration
- Shared among CDO objects
- Use in ASPs
- One Configuration object per user
- Should be application-scoped
24ConfigurationUsing the configuration object
Set Msg CreateObject(CDO.Message) Set Config
CreateObject(CDO.Configuration) Config.Fields
(cdoSMTPUserEmailAddress) jeff_at_samples.micros
oft.com Config.Fields(cdoSendUsingMethod)
cdoSendUsingExchange Config.Fields.Update Set
Msg.Configuration Config
25IAddressee Overview
- Supported by the Addressee object
- Supports name resolutionon a single name
- Resolve without creating a message
- Supports ambiguous name resolution
- Get free/busy information
26CDO and EventsTransport and Store
- SMTP and NNTP Transport events
- Events return CDO Messages
- Exchange Store Events
- Use CDO to manipulate content when messages are
created, moved, deleted or saved - Sinks can be scripts, Visual Basic or Visual C
DLLs
27CDO Messaging
28CDO Messaging Review
- Exchange 2000 natively supports MIME content
- CDO exposes MIME to the developer
- Access to body parts, Streams, Fields
- IDataSource for access to in-memory and stored
data - ADO Integration
- ADO Streams, Fields, Recordsets
- ADO for folder navigation
29Questions?
30(No Transcript)