Platform SDK: SMTP Server Events

ISmtpInCommandSink::OnSmtpInCommand

[This is preliminary documentation and subject to change.]

The ISmtpInCommandSink::OnSmtpInCommand method is called on registered inbound protocol event sinks when an SMTP inbound command has been received.

HRESULT OnSmtpInCommand(
  [in] IUnknown  *pServer,
  [in] IUnknown  *pSession,
  [in] IMailMsgProperties  *pMsg,
  [in] ISmtpInCommandContext  *pContext
);

Parameters

pServer
A reference to an object exposing the IMailMsgPropertyBag interface. This object contains information about this SMTP virtual service instance. Use QueryInterface to retrieve the IMailMsgPropertyBag interface on the object and use this interface to get and set server properties. Information within this object persists for the lifetime of the SMTP virtual service's process.
pSession
A reference to an object exposing the IMailMsgPropertyBag interface. This object contains information about this SMTP virtual service instance. Use QueryInterface to retrieve the IMailMsgPropertyBag interface on the object and use this interface to get and set session properties. Information within this object persists only for the duration of the protocol session and is destroyed when the session ends.
pMsg
A reference to the MailMsg object housing the current message content and properties.
pContext
A reference to the current SMTP protocol service context object.

Return Values

Remarks

Inbound protocol event sink COM classes expose this interface in order to receive notification that an inbound SMTP protocol command has been received by the protocol service. The type of notifications received by a particular sink is controlled using the Rule source binding property.

The first two arguments passed to the sink are references to objects that contain properties about the server and session respectively. Call QueryInterface to retrieve the IMailMsgPropertyBag interface on either object and use methods on this interface to access the server and session properties. Properties in the session object exist only for the lifetime of the SMTP protocol session.

The second argument is a reference to a MailMsg object. As message information is received from a transmitting client through the SMTP protocol, it is stored in the associated MailMsg object for the session. Sink objects use the IMailMsgProperties interface passed in the event method to interface with this MailMsg object. The information stored in the MailMsg object depends upon the list of received SMTP commands. For example, if the sink is notified of the "EHLO" SMTP protocol command, the MailMsg object will not contain recipient information or message content.

The fourth argument is a reference to an object containing context information about the SMTP connection, the SMTP command, the current SMTP status, and so one. Use methods on this interface to access this context information.