Implementing NNTP Event Sinks
To implement a Network News Transfer Protocol (NNTP) OnPost, OnPostEarly or OnPostFinal event sink, follow this procedure:
- Create a Component Object Model (COM) class that implements the INNTPOnPost, INNTPOnPostEarly, and INNTPOnPostFinal interfaces, respectively. You can do this using any programming language or scripting language that supports COM.
- For performance reasons, you may allow the source to cache the sink for subsequent use. In this case, implement the IEventIsCacheable interface. This interface consists of the IsCacheable method and should return the HRESULT value S_OK. When the event dispatcher thread first creates an instance of the sink COM class, it calls QueryInterface for this interface and calls the IsCacheable method. If S_OK is returned, it will cache the sink for subsequent events and an instance of the sink COM class need not be recreated for each event. The type information for the IEventIsCacheable interface is located in the Server Extension Objects (SEO) COM DLL SEO.DLL. (The type library is a resource in the DLL.)
- Register the class on the local server. The event dispatcher uses either the class identifier (CLSID) or the programmatic identifier to create a class instance when the event occurs. For scripts, you must register the appropriate Microsoft® Collaboration Data Objects (CDO) scripting host as the sink and configure it with the location of your script.
- Register a binding for the SMTP OnPostEarly, OnPost, or OnPostFinal event using the Server Extension Objects (SEO) or the smtpreg.vbs command-line Windows Scripting Host (WSH) script. See Managing Event Bindings.
The event type determines which action your object will take with the IMessage interface that is passed to it:
- OnPostEarly
- When the event dispatcher calls the OnPostEarly method on your sink, the sink is passed an IMessage interface on a Message object that contains only the message headers and transport envelope fields (the message contents have not yet arrived at this point). This event is primarily designed for performance. You can alter the NNTP processing for the posted message or to block posting altogether before the body of the post has been transmitted to the service.
- OnPost
- When the event dispatcher calls the OnPost method on your sink, the sink is passed an IMessage interface on a Message object that contains the message contents in its entirety. The message contents can be retrieved and examined but not modified; therefore, you cannot alter the message (or body part) Fields or the message stream in the transport. You can, however, modify the EnvelopeFields and therefore, change the newsgroups to which the message is to be posted, or change the NNTP processing that occurs for the message.
- OnPostFinal
- When the event dispatcher calls the OnPostFinal method on the sink, the sink is passed an IMessage interface on a Message object that contains the message contents in its entirety. For OnPostFinal events, the message has already been committed to disk or to the Exchange store, and its processing status cannot be changed. You can use this event to perform any special post-processing functionality, such as subsequently sending the message to a distribution list or to a special archive storage location.
See Also
Using the NNTP Message Envelope Fields
Implementing Sinks with Scripting Languages
IMessage Interface
Message COM Class
ADO Stream Object
Managing Event Bindings