This article was previously published under Q288156
This article has been archived. It is offered "as is" and will no longer be updated.
This article demonstrates how to write a Store Event sink for Exchange Server 2000 by using Visual C++.
To create a Store Event sink, follow these steps. Note that you must do your development on an Exchange 2000 server.
- In Visual C++, create a new project. In the dialog box, select ATL COM AppWizard and accept the default settings.
- On the Insert menu, click New ATL Object. Select Simple Object and click Next. Type a name for the object, and then click OK.
- Click the ClassView tab to switch to the ClassView in your workspace browser. Right-click the class that was created, click Implement Interface, and then click OK.
- In the list of available type libraries, select EXOLEDB Type Library (1.0), and then click OK.
- In the Implement Interface dialog box, select the ones you want to implement and click OK. For store events, you must select at least one of the following interfaces:
- IExStoreAsyncEvents: OnSave, OnDelete
- IExStoreSyncEvents: OnSyncSave, OnSyncDelete
- IExStoreSystemEvents: OnMDBStartup, OnMDBShutdown, OnTimer
- To avoid redefinition errors, rename the _SID_IDENTIFIER_AUTHORITY and the _SID structures in the EXOLEDB library. To do this, open the header file that was created for you, and change the following line
#import "C:\Program Files\Exchsrvr\bin\exoledb.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids
#import "C:\Program Files\Exchsrvr\bin\exoledb.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids,\
rename ("_SID_IDENTIFIER_AUTHORITY","EXOLEDB_SID_IDENTIFIER_AUTHORITY"), rename("_SID","EXOLEDB_SID")
- You can now expand the class that was created and see the list of functions for the interfaces that you chose. Double-click a function to go to the function definition. These functions are in a header file, and are inline functions that return the COM return code that indicates that they have not been implemented.
STDMETHOD(OnSyncDelete)(IExStoreEventInfo * pEventInfo, BSTR bstrURLItem, LONG lFlags)
- For the functions that you want to implement, remove the inline function, leaving just the function prototype. Be sure to end the prototype with a semicolon (;).
- Switch to the source (.cpp) file that matches the name of the header. Place your function implementations here.
// Import the ADO and CDOEX DLLs.
#import "C:\Program Files\Common Files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF"), named_guids
#import "C:\Program Files\Common Files\Microsoft Shared\CDO\cdoex.dll" no_namespace
STDMETHODIMP CATLSink::OnSyncSave(IExStoreEventInfo * pEventInfo, BSTR bstrURLItem, LONG lFlags)
HRESULT hr = S_OK;
// Only do this at the beginning of the transaction.
if (lFlags & EVT_SYNC_BEGIN)
// Cast pEventInfo to a IExStoreDispEventInfoPtr.
IExStoreDispEventInfoPtr pDispInfo = pEventInfo;
// Create a new message.
// Get the record that caused the event.
// This is the new message.
// Set up a reply.
iMsg->From = "email@example.com";
// Set the recipient to the sender of the message that caused the event.
iMsg->To = rec->Fields->GetItem("urn:schemas:httpmail:fromemail")->Value.bstrVal;
// Set up the subject string to contain the subject of the message that caused the event.
sprintf(szSubject,"Message Received: %s", (char*)(_bstr_t)rec->Fields->GetItem("urn:schemas:httpmail:subject")->Value.bstrVal);
iMsg->Subject = szSubject;
// Set up the text of the message to contain the URL to the message that caused the event.
sprintf(szTextBody, "The following item was received:\n%s", (char*)(_bstr_t)bstrURLItem);
iMsg->TextBody = szTextBody;
// Send the message.
iMsg = NULL;
- Compile and link your code. This automatically builds and registers a dynamic-link library (DLL). For the event sink to function, place the DLL in a COM+ application.
Article ID: 288156 - Last Review: February 28, 2014 - Revision: 3.3
- Microsoft Exchange 2000 Server Standard Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++, 32-bit Learning Edition 6.0
|kbnosurvey kbarchive kbhowto kbmsg KB288156|
Contact us for more help
Connect with Answer Desk for expert help.