Platform SDK: CDO for Windows 2000

ISMTPOnArrival Interface

The ISMTPOnArrival interface defines the interface between event sinks written with Microsoft Collaboration Data Objects for Windows 2000 (CDOSYS) and the Simple Mail Transfer Protocol (SMTP) service OnArrival event dispatcher.

IID
CD000026-8B95-11D1-82DB-00C04FB1625D
Extends
IDispatch

Member Summary

Method

Name Description
OnArrival Called by the SMTP event source on registered OnArrival event sinks when a new message arrives to the SMTP service.

Remarks

To implement an SMTP OnArrival event sink using CDO, you create and register a local Component Object Model (COM) class that provides an implementation of the CDO ISMTPOnArrival interface.

For more information on writing SMTP event sinks using CDO, see SMTP/NNTP Transport Event Sinks with CDO.

The passed CDO Message object is bound to an ADO Stream object containing the message contents within the SMTP transport. To commit any changes you make to the transport content, call IDataSource.Save. This does not affect the EnvelopeFields collection. Changes to the EnvelopeFields collection for the message are committed to the transport using the Fields.Update method for the collection.

If you want to rebind the Message object to another object, make sure to cache the reference to the ADO Stream object in the transport using the IDataSource.Source property. If you rebind the Message object without caching this reference, you will not be able to rebind the Message object to the transport stream.

Example

[C++,IDL]

The following code is an example of how to use the Active Template Library (ATL) to implement an SMTP OnArrival event sink.

#include "StdAfx.h"
#include "sinkproj.h"  // contains guids for this class
#include "resource.h"
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import <cdosys.dll> raw_interfaces_only no_namespace
class ATL_NO_VTABLE CMyClass :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CMyClass,&CLSID_MyClass>,
    public IDispatchImpl<ISMTPOnArrival,&__uuidof(ISMTPOnArrival),&LIBID_MyClass>
{
public:
     CMyClass() {}
DECLARE_REGISTRY_RESOURCEID(IDR_MyClass)
DECLARE_NOT_AGGREGATABLE(CMyClass)

BEGIN_COM_MAP(CMyClass)
  COM_INTERFACE_ENTRY(ISMTPOnArrival)
  COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

// ISMTPOnArrival
public:
   STDMETHOD(OnArrival) (/* in */ IMessage* pMsg, /* in,out */ CdoEventStatus* pEventStatus);
private:
   // any other custom methods you wish to use
   
};

STDMETHODIMP CMyClass::OnArrival( IMessage* pMsg, CdoEventStatus* pEventStatus)
{
   // TODO:  add sink code here
}
[Visual Basic]
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library
Implements CDO.ISMTPOnArrival

Private Sub ISMTPOnArrival_OnArrival( ByVal Msg As IMessage, pEventStatus as CdoEventStatus )
  Msg.TextBody = Msg.TextBody & vbCrLf & "Text added by the sink."
  Msg.DataSource.Save ' Commit the changes into the transport Stream
End Sub
[VBScript]
<SCRIPT LANGUAGE="VBScript">
Sub ISMTPOnArrival_OnArrival( ByVal Msg, EventStatus )
  Msg.TextBody = Msg.TextBody & vbCrLf & "Text added by the sink."
  Msg.DataSource.Save ' Commit the changes into the transport Stream
  ' code here
End Sub
</SCRIPT>

See Also

SMTP/NNTP Transport Event Sinks with CDO

IDataSource Interface

IDataSource.Source Property