msg332 developing transport event messaging solutions for windows and exchange max ciccotosto...

46
MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Upload: peregrine-marsh

Post on 05-Jan-2016

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

MSG332

Developing Transport Event Messaging Solutions for Windows and Exchange

Max Ciccotosto

Program Manager - Exchange

Microsoft Corporation

Page 2: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

AgendaSinks Overview and Basics

SMTP Service

What can you do with events?

Event model

Programming Language Support

AdvancedContent Conversion

Event registration

Interface descriptions

How to create transport and protocol event sinks

Page 3: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Exchange 2003 Vs. 2000

No changes in the Transport Infrastructure

Same events

Same interfaces

Exchange 2000 Sinks will work on 2003.

Added support for Retry

Improved documentation

Page 4: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Add recipient to messages from Internet

Page 5: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Windows SMTP Service

Store and forward relay

Mailing list (Distribution List or ‘DL’) expander

“Deliver” to Drop directory

“Pickup” from Pickup directory

Page 6: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Protocol And Transport EventsThe Goals

To allow the creation of a mail system on top of the Windows 2000 SMTP Service

To allow the extension of Exchange 2000 and Windows 2000 SMTP Service

Page 7: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Exchange

Exchange uses Windows SMTP ServiceExchange depends on SMTP Service

Exchange extends SMTP Service with events

Adds store (mailboxes), store driver (local delivery to store), a whole lot more

All messages go through events, even X.400 and RPC inbound/outbound

Page 8: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Protocol And Transport Events

Access to all message properties821, 822 and Transport specific properties

Many places in the code to “hook in”

COM based, C++ only

Support for Synch and Asynch events

Fast!

Page 9: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Event ModelProtocol Events

Extend SMTP protocol (ESMTP)

Modify existing SMTP protocol commands and responses

Transport EventsExtend message processing system (address resolution, restrictions processing, message routing)

Code runs on each message

Read/Write access to envelope and body

Executes in-process with IIS/SMTP

Page 10: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Uses For Protocol Events

Billing and charge-back based on number of connections, time of connections

Monitoring system via SMTP, implement new ESMTP commands

Provide new SMTP authentication methods

Provide RCPT checking

Custom anti-spam scripts

Page 11: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Uses For Transport Events

Forward all mail for a domain to a mailbox

Scan all inbound mail from the Internet for keyword, subject, attachment filename

Processing spans multiple internalmail systems

Virus checking

Spam (UCE) checkingStop mail with all numeric From: address

Stop mail with keywords in subject or body

Add a disclaimer to all outbound mail to the Internet

Apply custom restrictions

Page 12: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Event Overview

ProtocolCommand Events

TransportSubmission

Pre Categorizer

Categorizer

Post Categorizer

Routing

Store Driver

Page 13: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Transport CoreSMTP SMTP

ServiceServiceSMTP SMTP

ServiceService

PreCatPreCatEventEvent

PreCatPreCatEventEvent

PostCatPostCatEventEvent

PostCatPostCatEventEvent

Routing Routing EventEvent

Routing Routing EventEvent

SMTP SMTP ServiceServiceSMTP SMTP

ServiceService

Message Message CategorizerCategorizer

Message Message CategorizerCategorizer

Routing Engine Routing Engine (IMessageRouter)(IMessageRouter)Routing Engine Routing Engine

(IMessageRouter)(IMessageRouter)

Store Store SubmissionSubmission

Store Store SubmissionSubmission

MTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTS MTS OutOut

MTAMTAMTAMTA

CategorizerCategorizerEventsEvents

CategorizerCategorizerEventsEvents

Advanced Queuing

PreCatPreCatSinkSink

PreCatPreCatSinkSink

PostCatPostCatSinkSink

PostCatPostCatSinkSink

OnSubmissionOnSubmissionEventEvent

OnSubmissionOnSubmissionEventEvent

OnSubmissionOnSubmissionSinkSink

OnSubmissionOnSubmissionSinkSink

MTAMTAMTAMTA

Store Local Store Local DeliveryDelivery

Store Local Store Local DeliveryDelivery

MTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTS MTS OutOutMTSMTS InIn

MTSMTS InIn

Page 14: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Language Support

C++CDO_onArrival

OnSubmission EventScriptable, dual-interfacedCDO Message object gives easy access to message fields, attachments

Managed WrappersWrappers for all Transport ObjectsInterop abstractionhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmtps/html/writingmngsinks.asp

Page 15: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

CDO Sink

Page 16: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Content Conversion

Page 17: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Exchange Content

No Content ConversionSMTP Inbound from Internet

SMTP Outbound to Internet

Content ConversionMAPI-Submitted

TNEF

Outlook 2000

Outlook Web Access

Page 18: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Bifurcation

Recipients:Recipients:

Content:Content:DefaultDefault

Recipients:Recipients:

Content:Content:DefaultDefault

MailMsg

Internal UserExternal User

BodyBodyBodyBody

Recipients:Recipients:

Content:Content:S-TNEFS-TNEF

Recipients:Recipients:

Content:Content:S-TNEFS-TNEF

Internal User

MailMsgRecipients:Recipients:

Content:Content:MIMEMIME

Recipients:Recipients:

Content:Content:MIMEMIME

External User

BodyBodyBodyBody

MailMsg

MAPIMAPIClientClientMAPIMAPIClientClient PrePre

CatCatPrePreCatCat

SMTPSMTPSMTPSMTPPostPostCatCat

PostPostCatCat

Page 19: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Exchange Issues

Not easy to modify content of MAPI/OWA-submitted messagesUNLESS it is going to “The Internet”

Design architecture so you don’t need to modify TNEF

Much easier to write Store Event sink to modify internal messages

Transport Events best suited for “the border”

Bottom LineBottom Line

Page 20: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Disclaimer Sink

Page 21: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Event Registration

Page 22: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Server Event Bindings

Stored in Metabase/smtpsvc/<instanceNumber>/EventManager

Event dispatcher (AQ) uses bindings to match sinks to events

Rules (“filter”)

Priority for each eventEvent sinks executed in order of priority

Same priority events executed in random order

Page 23: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Event Rules

Limit event call to certain messages

Case-insensitive

Can filter on MAIL FROM=, RCPT TO=, and EHLO=

Available on Submission, PreCat, PostCat events

Exchange tipTo catch MAPI-submitted messages, must have no filter rule

Page 24: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Event Rule Example

MAIL FROM= user1@domain;RCPT TO=user2@domain

Makes sink only fire on messages from user1@domain OR to user2@domain

Can use wildcards: @domain, user@foo*

Can have multiple RCPT TO:s, multiple MAIL FROM:s, multiple EHLOs; each is OR’d

Page 25: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Creating Bindings

1. Use smtpreg.vbs available in the Exchange SDK.

2. Do it yourself:SEO used to modify Metabase to create bindings

Tools for registration, de-registration, debugging (list binding)

VBScript, or can make sink self-registering via regsvr32 entry points

Troubleshooting: list bindings to see what is installed

Page 26: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Registering Sinks:SMTPREG

Page 27: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Protocol Events

Page 28: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Protocol Event Sinks

Sink implements one or more sink interfaces

Each sink fired based on what category the session is in

InboundOn Inbound Command, On Server Response

OutboundSession Start, Message Start, Per-Recipient,

Before Data, Session End

Page 29: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Protocol Event Sinks

ISmtpInCommandSinkCalled when inbound SMTP command is receivedISmtpOutCommandSinkCalled when outbound SMTP command is to be sentISmtpServerResponseSinkCalled when server responds to previously sent command

Page 30: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Protocol Event InterfacesGeneral Interface Property BagsIServer - Information about the SMTP Virtual Server

ISession – Information about the current SMTP Session

IMailMsgProperties – Information about the current message being received

Context InterfaceSystem-implemented interface

Sink can call to get and set information about commands and responses, set state

Page 31: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Transport Events

Page 32: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Transport Events

IMailTransportSubmissionOnSubmission event

Recipients should be added here (before categorizer-related events)

IMailTransportOnPreCategorizeShould be used to check recipient lists

All recipients should be present

IMailTransportOnPostCategorizeDLs will be expanded – actual recipients will be listed

Page 33: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Transport EventsRelated Functions

IMailTransportNotify Sink may return asynchronously, return MAIL_TRANSPORT_S_PENDING

That message will be halted and wait for callback via this function

Dispatcher will allow other messages to be processed until the thread pool limit

Page 34: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Transport EventsRelated Functions

IsCacheableIf not defined, sink instance deleted after exit

Overhead of CoCreateInstance() for each event raised if not cache-able

Sink must be re-entrant/thread-safeNo shared data without proper locking

Protocol events also can implement

Page 35: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

IMailMsg

OnSubmission/PreCat/PostCat sinks get object IMailMsg

IMailMsgProperties objectMapContent() – maps content of message into memory

CopyContentToFile() – copies content of message to file

GetProperty()/PutProperty() – reads and writes properties

Many methods

Page 36: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Subsequent Sinks

Sink returns S_OKOther sinks at same or lower priority are called

Sink returns S_FALSEOther sinks at same or lower priority are not called

Page 37: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Recipe For Creating Transport

Event Sink

Page 38: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Creating Transport Sink

1. Implement sink interface method

2. Register event using smtpreg.vbs1. Register COM interface of sink in registry

2. Register interface in event binding database in metabase via SEO

3. Send messages through, watch it fire!

Page 39: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Managed Sink

Page 40: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Ask The ExpertsGet Your Questions Answered

Talk one-on-one with a community of your peers

Community Experts: Microsoft product teams, consultants and Tech*Ed speakers

Resources: whiteboards, internet, etc.

Location: in the middle of the Exhibit Hall

Hours: at least 12-3:30p every day

I will be at the ATE after this session

Page 41: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Community Resources

Community Resourceshttp://www.microsoft.com/communities/default.mspx

Most Valuable Professional (MVP)http://www.mvp.support.microsoft.com/

NewsgroupsConverse online with Microsoft Newsgroups, including Worldwidehttp://www.microsoft.com/communities/newsgroups/default.mspx

User GroupsMeet and learn with your peershttp://www.microsoft.com/communities/usergroups/default.mspx

Page 42: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Suggested Reading And Resources

The tools you need to put technology to work!The tools you need to put technology to work!

TITLETITLE AvailableAvailable

Microsoft® Exchange Server 2003 Microsoft® Exchange Server 2003 Administrator's Companion: 0-Administrator's Companion: 0-7356-1979-47356-1979-4

9/24/039/24/03

Microsoft® Windows® Server Microsoft® Windows® Server 2003 Administrator's 2003 Administrator's Companion: 0-7356-1367-2Companion: 0-7356-1367-2

TodayToday

Microsoft Press books are 20% off at the TechEd Bookstore

Also buy any TWO Microsoft Press books and get a FREE T-Shirt

Page 43: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Thank You!!!

[email protected]

Please Fill Out The Evaluation Form

Page 44: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

Community Resources

Community Resourceshttp://www.microsoft.com/communities/default.mspx

Most Valuable Professional (MVP)http://www.mvp.support.microsoft.com/

NewsgroupsConverse online with Microsoft Newsgroups, including Worldwidehttp://www.microsoft.com/communities/newsgroups/default.mspx

User GroupsMeet and learn with your peershttp://www.microsoft.com/communities/usergroups/default.mspx

Page 45: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

evaluationsevaluations

Page 46: MSG332 Developing Transport Event Messaging Solutions for Windows and Exchange Max Ciccotosto Program Manager - Exchange Microsoft Corporation

© 2003 Microsoft Corporation. All rights reserved.© 2003 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.