我已经试验过了,没用的,邮件倒是接收回来了,没有办法解析,给你一个我收到的邮件:
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from smtp.sanxing.com (unknown [61.190.152.113])
by sohumx.sohu.com (Postfix) with ESMTP id 3E414A4BB5
for <[email protected]>; Sun,  1 Jun 2003 11:42:30 +0800 (CST)
Received: from 192.168.0.4 ([192.168.0.4]) by smtp.sanxing.com with Microsoft SMTPSVC(6.0.3790.0);
 Sun, 1 Jun 2003 11:42:28 +0800
From: 代码测试 <[email protected]>
To: =?GB2312?B??= <[email protected]>
Cc: [email protected] <[email protected]>, 
Subject:=?GB2312?B?dGVzdA==?=
X-Priority:Normal
X-MSMail-Priority:Normal
Importance:Normal
X-Mailer: Huolx.Pubclass
MIME-Version: 1.0
Status: RO
X-UIDL: 1054438923.10130_8.mx27.mail.sohu.com
Content-Type: multipart/mixed;
   boundary="----=_NextPart_000_00D6_01C29593.AAB31770"
Message-ID: <[email protected]>
X-OriginalArrivalTime: 01 Jun 2003 03:42:28.0203 (UTC) FILETIME=[D2B1A3B0:01C327EF]
Date: 1 Jun 2003 11:42:28 +0800------=_NextPart_000_00D6_01C29593.AAB31770
Content-Type: text/plain;
   charset="gb2312"
Content-Transfer-Encoding: base64dGVzdA==
------=_NextPart_000_00D6_01C29593.AAB31770--

解决方案 »

  1.   

    目前电子邮件采用MIME格式。我用了1个星期的时间做了一个vb.net版的pop3接收组件,MIME格式好理解,但是并不是所有的电子邮件编写工具都严格遵守标准MIME格式。就是OE中文版和英文版对于邮件中的文本信息采用的编码都不一样,你可以自己测试一下,我在分析新浪编写MIME格式的电子邮件中附件RAR文件的Base64编码都不能用.net内置的base64转换函数转换,只能用Base64类自己转换。
      

  2.   

    我觉得是
    String Logon(TcpClient tcpc,string user,string pwd)
    {
     string strret;
     strret=SendPopCmd(tcpc,"user" + user);--->"user "
     strret=SendPopCmd(tcpc,"pass" + pwd);---->"pass "
     return strret;
    }
      

  3.   

    //1,C#D using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace _123
    {
    /// <summary>
    /// testEmailREC 的摘要说明。
    /// </summary>
    public class testEmailREC : System.Web.UI.Page
    {
    //
    System.Net.Sockets.TcpClient tcpC=new System.Net.Sockets.TcpClient();
    System.Net.Sockets.NetworkStream netstream;
    string thisResponse;
    protected System.Web.UI.WebControls.TextBox pass;
    protected System.Web.UI.WebControls.TextBox user;
    protected System.Web.UI.WebControls.TextBox host;
    protected System.Web.UI.WebControls.Label Label1;
    protected System.Web.UI.WebControls.Label Label2;
    protected System.Web.UI.WebControls.Label Label3;
    protected System.Web.UI.HtmlControls.HtmlGenericControl DIV1;
    // protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    this.DIV1.Visible=false;
    this.ReadMail(this.host.Text,this.user.Text,this.pass.Text);

    }
    private string SendCommand(System.Net.Sockets.NetworkStream netstream , String sToSend)
    {
    // send command strings and return the response
    Byte[] bData=System.Text.Encoding.ASCII.GetBytes(sToSend.ToCharArray());
    netstream.Write(bData,0,bData.Length);
    return(GetResponse(netstream));
    }
    //
    private string GetResponse(System.Net.Sockets.NetworkStream netstream)
    {
    //check if there is a response to get and return it
    Byte[] bytes=new Byte[tcpC.ReceiveBufferSize];
    int ret =netstream.Read(bytes, 0, bytes.Length);
    // Returns the data received 
    string returndata  = System.Text.Encoding.Default.GetString(bytes);//.ASCII.GetString(bytes);
                return returndata; }
    //
    private void ReadMail(string host,string user,string pass)
    {
    //initialise objects
    //
    //open connection to server
    try
    {
    tcpC.Connect(host,110);
    }
    catch(Exception ex)
    {
    Response.Write("Error connecting to host: " + ex.Message+ " - Please check your details and try again");
    Response.End();
    }
    //
    //get response
    netstream = tcpC.GetStream();
        thisResponse=GetResponse(netstream);
    //
                //enter user name
        thisResponse=SendCommand(netstream,"user " +user+"\r\n");
    //
    //enter password
       thisResponse=SendCommand(netstream,"pass " + pass+"\r\n");
    //
    // check if logged in ok

    if (thisResponse.Substring(0,4)!="-ERR")
    {
    this.Response.Write("<font face=courier>Logged in OK <BR>");
    }
    else
    {
    this.Response.Write("Error logging in, check your user details and try again<BR>");
    Response.Write("<P>" +thisResponse);
    Response.End();
    } thisResponse=SendCommand(netstream,"stat" + "\r\n"); //split string to array;
    string[] tmpArray;
    tmpArray=thisResponse.Split(' '); //int thisMess;
    string numMess=tmpArray[1];
                
    this.Response.Write("<p><hr>");
                thisResponse = "";
    //
    // if (Int32.Parse(numMess) > 0)
    {
    this.Response.Write("Messages: " +numMess + "<br>");
    for(int thisMess = 1;thisMess<=Int32.Parse(numMess);thisMess++)
    {

    thisResponse += (SendCommand(netstream,"top " +thisMess+ " 10" + "\r\n")).Replace("\r\n","<br>");
    }
    }
    else
    {
    Response.Write("Messages: None" + "<br>");
    }

    //
                thisResponse += (SendCommand(netstream,"stat" + "\r\n")).Replace("\r\n","<br>"); //````````````````````````
    thisResponse.Replace("+OK","ゆ");//there was a bug with ゆ!!
    //
    tmpArray = thisResponse.Split('ゆ');
    //
    Response.Write(thisResponse); for(int msg=0;msg<=tmpArray.Length-1;msg++)
    { Response.Write("<h3>#" + msg + "</h1>" + tmpArray[msg] + "<p>");
    }            // close connection
                thisResponse=SendCommand(netstream,"QUIT" + "\r\n");
                tcpC.Close();
    }
    }
    }
      

  4.   

    ’2 VB.net的<%@page%>
    <HTML><HEAD><title>Pop3 mail check</title></HEAD>
    <body bgcolor=white><%if isPostback then
    readMail(host.text,user.text,pass.text)
    else%><form id=calc method=post runat="server"><P>
    Host <asp:TextBox id=host runat="server"></asp:TextBox>
    <P>
    User <asp:TextBox id=user runat="server"></asp:TextBox>
    <P>
    Pass <asp:TextBox TextMode=Password id=pass runat="server"></asp:TextBox><P>
    <asp:Button id=Button1 runat="server" Text="Login"></asp:Button></FORM><%end if%></body></HTML><script language="vb" runat="server">
    Dim tcpC as New system.net.sockets.TcpClient()

    ' send command strings and return the response
    Function SendCommand(byRef netstream as System.Net.Sockets.NetworkStream,byVal sToSend as String)

    Dim bData() as Byte = Encoding.ASCII.GetBytes(sToSend.ToCharArray)
    netstream.Write(bData,0,bData.Length())
    Return GetResponse(netstream)
    End Function

    ' check if there is a response to get and return it
    Function GetResponse(byRef netstream as System.Net.Sockets.NetworkStream)   Dim bytes(tcpC.ReceiveBufferSize) As Byte
          Dim ret as integer = netStream.Read(bytes, 0, bytes.length)
          
          
          
          ' Returns the data received 
          Dim returndata As String = Encoding.ASCII.GetString(bytes)
          return returndata

    End Function

    Function ReadMail(host as string, user as string, pass as string)

    ' initialise objects
    Dim netstream as System.Net.Sockets.NetworkStream

    Dim thisResponse as string

    ' open connection to server
    try
    tcpC.Connect(host,110)
    catch ex as exception 
    response.write("Error connecting to host: " & ex.message & " - Please check your details and try again")
    response.end
    end try

    ' get response
    netstream = tcpC.GetStream()
    thisResponse=GetResponse(netstream)
    ' enter user name
    thisResponse=SendCommand(netstream,"user " & user & vbCrLF) ' enter password
    thisResponse=SendCommand(netstream,"pass " & pass & vbCrLf)

    ' check if logged in ok
    if not left(thisResponse,4)="-ERR" then
    response.write("<font face=courier>Logged in OK <BR>")
    else
    response.write("Error logging in, check your user details and try again<BR>")
    response.write("<P>" & thisresponse)
    response.end
    end ifthisResponse=SendCommand(netstream,"stat" & vbCrLf)
    dim tmpArray() as string
    tmpArray = split(thisResponse," ")dim thisMess as integer
    dim numMess as string = tmpArray(1)response.write("<p><hr>")thisResponse = ""if cint(numMess) > 0 then
    response.write("Messages: " & numMess & "<br>")
    for thisMess = 1 to cint(numMess)
    thisResponse += replace(SendCommand(netstream,"top " & thisMess & " 10" & vbCrLf),vbcrlf,"<br>") next
    else
    response.write("Messages: None" & "<br>")
    end if
    thisResponse += replace(SendCommand(netstream,"stat" & vbCrLf),vbcrlf,"<br>")tmpArray = split(thisResponse,"+OK")
    response.write(thisresponse)Dim msg as integer
    for msg = 1 to tmpArray.length-1 response.write("<h3>#" & msg & "</h1>" & tmpArray(msg) & "<p>")next' close connection
    thisResponse=SendCommand(netstream,"QUIT" & vbCrLF)
    tcpC.close

    End Function

    </script>
      

  5.   

    接收到的是大段的string 不过它们的格式很好控制,你可以readln()然后判断 subject From
    RecTime 等关键字!!