Managed Event Sink on Exchange 2003

Managed Event Sink on Exchange 2003

Post by Marc-andre » Sat, 20 May 2006 09:18:50

Hi NG!!

I have a problem here getting an handle on the message that triggered
the event. I found some code on but it doesn't work.

here is what i have:

Interop.CDOEx.dll <- abstract for cdoex.dll that i took in bin folder
Interop.ExOLDEDB.dll <- same as above...
Interop.ExEvtSnk.dll <- absract for exentsnk.tlb from the Exchange SDK

I created a CSharp Windows Lib project with Visual Studio 2005. I added
reference to System.EnterpriseServices, adodb and my 3 dll above.

My event fire but the handle never get created on the message and it
never goes to my catch block

does anybody have and idea?

thanks !!

Marc-andre Poupier

Here is my code:
using System;
using System.Collections.Generic;
using System.Text;
using cdo = Interop.CDOEx;
using Interop.ExOLEDB;
using System.EnterpriseServices;
using System.IO;

namespace KeystoneFaxSAC
public class ChangeMessageClass : ServicedComponent, IExStoreSyncEvents

public void OnSyncDelete(IExStoreEventInfo pEventInfo, string
bstrURLItem, int lFlags)


public void OnSyncSave(IExStoreEventInfo pEventInfo, string
bstrURLItem, int lFlags)
cdo.Message iMessage = new cdo.MessageClass();
StreamWriter w = new StreamWriter("C:\\SinkC.txt", true);
w.WriteLine("New Message created");
iMessage.DataSource.Open(bstrURLItem, null,
ADODB.RecordOpenOptionsEnum.adOpenSource, "", "");
w.WriteLine("Message Subject: " + iMessage.Subject);
catch (Exception ex)
StreamWriter err = new StreamWriter("C:\\SinkC.txt", true);
err.WriteLine("An error occured");
err.WriteLine("Message: {0}", ex.Message);
err.WriteLine("Stack Trace: {0}", ex.StackTrace);

Managed Event Sink on Exchange 2003

Post by Jeff Garma » Wed, 02 Aug 2006 22:56:38

Hello Mar-andre,

Have you tried the sample code that is available in the SDK?

And also the other reference in the SDK:

There appears to be a couple of differences from your sample below and the
ones in the SDK, so you may want to have a look to confirm.
We usually suggest the above two references when ever working with managed
store sinks.

- Jeff