다음을 통해 공유


OnArrival Method

Topic Last Modified: 2006-06-13

Called by the SMTP event source on bound OnArrival event sinks when a new message has arrived to the SMTP service.

Applies To

ISMTPOnArrival Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

Sub OnArrival(    ByVal Msg As CDO.Message,
        EventStatus As CdoEventStatus)
HRESULT OnArrival
(
        IMessage* Msg,
        CdoEventStatus* EventStatus
);

Parameters

  • Msg
    The IMessage interface on a Message object holding the message that arrived.
  • EventStatus
    On return, the status of the event. The event sink signals to the source whether to continue notifying subsequent event sinks, or to stop and return. These values make up the CdoEventStatus enumeration in the type library.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The Message object passed to the OnArrival method is in unexpanded format. The recipient addresses have not been resolved or expanded, and are thus still in the format in which the sending message transfer agent (MTA) placed them in the message envelope.

For SMTP OnArrival events, the message content is read-write and can be modified by the sink. Additionally, some of the envelope fields can be modified. For more information, see SMTP/NNTP Transport Event Sinks with CDO.

The passed Collaboration Data Objects (CDO) Message object is bound to a Microsoft® ActiveX® Data Objects (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.

The transport ADO Stream object is required to modify the message contents in the SMTP transport. If you want to bind the Message object to another object within your sink, using for example IDataSource.OpenObject or IDataSource.SaveToObject, make sure to first retrieve the transport Stream object reference using the Message object's IDataSource.Source property. If you do not, you will not be able to rebind the Message object to the transport Stream object and consequently you will not be able to update the message contents in the transport.

The OnArrival event for the SMTP service is synchronous, meaning that the event dispatcher thread is blocked for the length of time required for either all bound event sinks to be created (if necessary) and executed, or until a sink preemptively stops event notifications by returning the EventStatus parameter with the value cdoSkipRemainingSinks.