Blog Post

Exchange Team Blog
2 MIN READ

Writing Managed Sinks for SMTP and Transport Events

The_Exchange_Team's avatar
The_Exchange_Team
Platinum Contributor
Jun 16, 2004

Summary: This document provides developers an overview of how to write event sinks for SMTP and Transport events in managed code using wrappers that obscure some of the details of communicating with the unmanaged server.

Introduction

Writing event sinks in managed code allows the programmer to make use of the Microsoft® .NET Framework and to more efficiently write the code that is necessary for the sink. Writing managed sinks can be somewhat difficult, however, because event sink interfaces were designed primarily for C++ programmers and are therefore not very easy to use in a language such as C#. In addition, some of the methods that are imported using Tlbimp.exe will not work unless they are modified at the intermediate language (IL) level. However, these inconsistencies in the imported assemblies have been fixed in the events' primary interop assembly (PIA) provided, and other interfaces that were inconvenient to use have also been wrapped so that they are easier to use from managed code.

These managed wrappers wrap each of the methods on the original interfaces and correctly communicate with the unmanaged server. In addition, some of the original methods are exposed as properties instead of pairs of methods. For example, all pairs of Set and Query methods are exposed as properties.

This document assumes that the reader has a working knowledge of the .NET Framework, COM, COM Interop and Microsoft Windows® 2000 SMTP Service Events.

For information about event sinks in general, see Microsoft Windows 2000 SMTP Service Events. As described in that document, sinks can implement a number of interfaces to handle corresponding events on the server. The methods of those interfaces are then called when the appropriate event is triggered and certain parameters are passed in.

How to Write a Managed Event Sink in C#: Step by Step

To write a managed event sink, you must link to the PIA that contains the necessary interfaces and implement the interfaces that correspond to the events that need to be handled. Optionally, you can link to the assembly that contains the easier-to-use wrappers for these interfaces.

Read the rest on MSDN web site...

Pretish Abraham

Updated Jul 01, 2019
Version 2.0

12 Comments

  • Chris, is there anything in particular you would like more documentation about? Ill try digging up something.
  • This is a reprint of an MSDN article which is over a year old. It links to a 4 year old article. Not that either of these articles is bad, but most people with a strong interest in writing event sinks will have already seen these. There's not a whole lot of documentation on event sinks which isn't contained either in this article or the links which spread from it.

    For those who want more in depth documentation, where do we turn? "Programming Microsoft Outlook and Microsoft Exchange 2003" only manages to devote 3 pages to the subject.