Exemple #1
0
        /// parses a new response object from a response string
        public static SmtpResponse Parse(string line)
        {
            SmtpResponse response = new SmtpResponse();

            if (line.Length < 4)
            {
                throw new SmtpException("Response is to short " +
                                        line.Length + ".");
            }

            if ((line[3] != ' ') && (line[3] != '-'))
            {
                throw new SmtpException("Response format is wrong.(" +
                                        line + ")");
            }

            // parse the response code
            response.StatusCode = Int32.Parse(line.Substring(0, 3));

            // set the rawsponse
            response.RawResponse = line;

            // set the response parts
            response.Parts = line.Substring(0, 3).Split(';');

            return(response);
        }
	/// parses a new response object from a response string
	public static SmtpResponse Parse( string line ) {
	    SmtpResponse response = new SmtpResponse();
	    
	    if( line.Length < 4 ) 
		throw new SmtpException( "Response is to short " + 
					   line.Length + ".");
	    
	    if( ( line[ 3 ] != ' ' ) && ( line[ 3 ] != '-' ) )
		throw new SmtpException( "Response format is wrong.(" + 
					 line + ")" );
	    
	    // parse the response code
	    response.StatusCode = Int32.Parse( line.Substring( 0 , 3 ) );
	    
	    // set the rawsponse
	    response.RawResponse = line;

	    // set the response parts
	    response.Parts = line.Substring( 0 , 3 ).Split( ';' );

	    return response;
	}
        // read a line from the server
        public void ReadResponse( )
        {
            string line = null;

            byte[] buffer = new byte[4096];

            int readLength = stream.Read(buffer, 0, buffer.Length);

            if (readLength > 0)
            {
                line = encoding.GetString(buffer, 0, readLength);

                line = line.TrimEnd(new Char[] { '\r', '\n', ' ' });
            }

            // parse the line to the lastResponse object
            lastResponse = SmtpResponse.Parse(line);

            #if DEBUG
            DebugPrint(line);
            #endif
        }
	// read a line from the server
	public void ReadResponse( ) {
	    string line = null;
	    
	    byte[] buffer = new byte[ 4096 ];
	    
	    int readLength = stream.Read( buffer , 0 , buffer.Length );
	    
	    if( readLength > 0 ) { 
	    
		line = encoding.GetString( buffer , 0 , readLength );
		
		line = line.TrimEnd( new Char[] { '\r' , '\n' , ' ' } );
			
	    }
	   
	    // parse the line to the lastResponse object
	    lastResponse = SmtpResponse.Parse( line );
	   
	    #if DEBUG
	      DebugPrint( line );
	    #endif
	}