コード例 #1
0
        /// <summary>
        /// Is called when MAIL command has completed.
        /// </summary>
        /// <param name="op">Asynchronous operation.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>op</b> is null reference.</exception>
        private void MailCommandCompleted(SMTP_Client.MailFromAsyncOP op)
        {
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            try{
                if (op.Error != null)
                {
                    Dispose(op.Error);
                }
                else
                {
                    SMTP_Client.RcptToAsyncOP rcptOP = new SMTP_Client.RcptToAsyncOP(
                        this.To,
                        IsDsnSupported() ? m_pRelayItem.DSN_Notify : SMTP_DSN_Notify.NotSpecified,
                        IsDsnSupported() ? m_pRelayItem.OriginalRecipient : null
                        );
                    rcptOP.CompletedAsync += delegate(object s, EventArgs <SMTP_Client.RcptToAsyncOP> e){
                        RcptCommandCompleted(rcptOP);
                    };
                    if (!m_pSmtpClient.RcptToAsync(rcptOP))
                    {
                        RcptCommandCompleted(rcptOP);
                    }
                }
            }
            catch (Exception x) {
                Dispose(x);
            }
        }
コード例 #2
0
        /// <summary>
        /// Is called when RCPT command has completed.
        /// </summary>
        /// <param name="op">Asynchronous operation.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>op</b> is null reference.</exception>
        private void RcptCommandCompleted(SMTP_Client.RcptToAsyncOP op)
        {
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            try{
                if (op.Error != null)
                {
                    Dispose(op.Error);
                }
                else
                {
                    // Start sending message.
                    SMTP_Client.SendMessageAsyncOP sendMsgOP = new SMTP_Client.SendMessageAsyncOP(m_pRelayItem.MessageStream, false);
                    sendMsgOP.CompletedAsync += delegate(object s, EventArgs <SMTP_Client.SendMessageAsyncOP> e){
                        MessageSendingCompleted(sendMsgOP);
                    };
                    if (!m_pSmtpClient.SendMessageAsync(sendMsgOP))
                    {
                        MessageSendingCompleted(sendMsgOP);
                    }
                }
            }
            catch (Exception x) {
                Dispose(x);
            }
        }
コード例 #3
0
ファイル: Relay_Session.cs プロジェクト: nbhopson/QMail
        /// <summary>
        /// Is called when MAIL command has completed.
        /// </summary>
        /// <param name="op">Asynchronous operation.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>op</b> is null reference.</exception>
        private void MailCommandCompleted(SMTP_Client.MailFromAsyncOP op)
        {
            if(op == null){
                throw new ArgumentNullException("op");
            }

            try{
                if(op.Error != null){
                    Dispose(op.Error);
                }
                else{
                    SMTP_Client.RcptToAsyncOP rcptOP = new SMTP_Client.RcptToAsyncOP(
                        this.To,
                        IsDsnSupported() ? m_pRelayItem.DSN_Notify : SMTP_DSN_Notify.NotSpecified,
                        IsDsnSupported() ? m_pRelayItem.OriginalRecipient : null
                    );
                    rcptOP.CompletedAsync += delegate(object s,EventArgs<SMTP_Client.RcptToAsyncOP> e){
                        RcptCommandCompleted(rcptOP);
                    };
                    if(!m_pSmtpClient.RcptToAsync(rcptOP)){
                        RcptCommandCompleted(rcptOP);
                    }
                }
            }
            catch(Exception x){
                Dispose(x);
            }
        }