我在这里发不了,说是不要发损坏csdn的言论,有点儿莫名其妙。
所以我就发到了微软的讨论区,由于英文不好,写得也是有点儿莫名其妙。
希望高手能帮帮我。谢谢。
地点。
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=370963&SiteID=1&mode=1100分献上。

解决方案 »

  1.   

    这里发发试试看。我的代码是用.net 2.0写的,我先取得邮件数,然后循环调用ReceiveMail来接收各个邮件,第一个邮件都可以接收下来,第二个邮件
    nwStream.DataAvailable就始终为false了。如果不判断nwStream.DataAvailable的话,除第一个邮件外,其余全是0字节。
    第二个问题:为什么我先WriteToStream(ref nwStream, "LIST\r\n") (向网络流中写入LIST,列出邮件数),之后在读的时候,有时候是上一个写流操作的结果,有时候甚至把连接服务器时的提示信息都读出来了,很不隐定,这究竟是什么原因?谢谢!
      

  2.   

    下面是writeToStream和ReadFromStream的代码.
    ReceiveMail的代码,这里发不了,还是到微软社区上看。
    public void WriteToStream(ref NetworkStream nwStream, string content)
            {
                try
                {
                    byte[] bContent = Encoding.Default.GetBytes(content);
                    nwStream.Write(bContent, 0, bContent.Length);
                }
                catch
                {
                    ErrorEventArgs e = new ErrorEventArgs("error");
                    OnPop3Error(e);
                }
            }        public void ReadFromStream(ref NetworkStream nwStream, ref string returnMsg)
            {
                try
                {
                    byte[] readBuffer = new byte[4096];                int length = nwStream.Read(readBuffer, 0, readBuffer.Length);
                    returnMsg = Encoding.Default.GetString(readBuffer, 0, length);
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    ErrorEventArgs e = new ErrorEventArgs("error");
                    OnPop3Error(e);
                }
            }
      

  3.   

    user,pass,stat你用streamreader读一行,直接判断有没+OK,之后
    循环邮件数,每个list,先读一行判断+ok,然后一直读到
    str=reader.ReadLine();
    while(str!=".")
    {
    strbu.Append(String.Concat(str, "\r\n"));
    WaitForResponse(ref reader, 1);
    str = reader.ReadLine();
    }
    strbu.Append("\r\n");