以下是我从163和sohu收到的邮件,现在想转换为正常的邮件,不知道该怎么做?
163应该是qb编码,sohu好象是base64编码,但是里面又有别的。请高手帮忙,给点资料参考一下,如果能有代码,不胜感激!分不够可以再加!
163:
+OK 963 octetsReceived: from smtp119.sohu.com (unknown [61.135.132.105]) by mx13 (Coremail) with SMTP id P4DoW1w7rkLEB_cF.1 for <[email protected]>; Tue, 14 Jun 2005 10:05:16 +0800 (CST)X-Originating-IP: [61.135.132.105]Received: from ZXK-LYB (unknown [218.4.145.82]) by smtp119.sohu.com (Postfix) with ESMTP id D3BC700DF0A for <[email protected]>; Tue, 14 Jun 2005 10:05:01 +0800 (CST)Date: Tue, 14 Jun 2005 10:03:43 +0800From: "lyb" <[email protected]>To: "yuranccc_2003" <[email protected]>Subject: testX-mailer: Foxmail 5.0 [cn]Mime-Version: 1.0Content-Type: text/plain; charset="gb2312"Content-Transfer-Encoding: base64Message-Id: <[email protected]>eXVyYW5jY2NfMjAwM6OsxPq6w6OhDQoNCgkgICAgICAgICAgICAgICAgICBhYWFhYQ0KDQqhoaGhoaGhoaGhoaGhoaGh1sINCsDxo6ENCiAJCQkJDQoNCqGhoaGhoaGhoaGhoaGhoaFseWINCqGhoaGhoaGhoaGhoaGhoaFhYmlhbmRiZWxAc29odS5jb20NCqGhoaGhoaGhoaGhoaGhoaGhoaGhMjAwNS0wNi0xNA0Ksohu:
+OK 1062 octetsReturn-Path: <[email protected]>Delivered-To: [email protected]: from 163.com (unknown [220.181.31.172]) by sohumx08.sohu.com (Postfix) with SMTP id 9DBA0002797F for <[email protected]>; Tue, 14 Jun 2005 10:10:15 +0800 (CST)Received: from ZXK-LYB (unknown [218.4.145.82]) by smtp10 (Coremail) with SMTP id iwDdp5A8rkKo9KUC.1 for <[email protected]>; Tue, 14 Jun 2005 10:10:25 +0800 (CST)X-Originating-IP: [218.4.145.82]Date: Tue, 14 Jun 2005 10:08:50 +0800From: "lyb" <[email protected]>To: "abiandbel" <[email protected]>Subject: testX-mailer: Foxmail 5.0 [cn]Mime-Version: 1.0Status: ROX-UIDL: 1118714901.28337_69.mx59Content-Type: text/plain; charset="gb2312"Content-Transfer-Encoding: base64Message-Id: <[email protected]>X-Sohu-Antivirus: 0YWJpYW5kYmVso6zE+rrDo6ENCg0KCQkJdGVzdHRlc3S6w7rDo6GjoQ0KDQqhoaGhoaGhoaGhoaGhoaGh1sINCsDxo6ENCiAJCQkJDQoNCqGhoaGhoaGhoaGhoaGhoaFseWINCqGhoaGhoaGhoaGhoaGhoaF5dXJhbmNjY18yMDAzQDE2My5jb20NCqGhoaGhoaGhoaGhoaGhoaGhoaGhMjAwNS0wNi0xNA0K

解决方案 »

  1.   

    string base64="sLK1wsmtt6K24LeiyP21yLfW";
    byte[] data = System.Convert.FromBase64String(base64);
    MessageBox.Show(System.Text.Encoding.GetEncoding("gb2312").GetString(data));
      

  2.   

    是不是一般都用base64 编码了啊!不知道怎么样把以上的编码分离成有用的信息?是不是要对这些编码字符串进行处理,才能得到发件人、收件人、发送时间等这样的信息?有没有算法?收到的编码前面信息不一样啊!
      

  3.   

    1.针对不同邮件格式解析邮件内容,具体实现可以考虑xml,可以得到各个信息头字段,包括编码格式等.
    2.根据不同的编码格式解码不同的内容(可能正文会分多个部分,各部分编码不同,如多媒体邮件)
      

  4.   

    参考RFC:
    RFC #733
    RFC 2045 - Multipurpose Internet Mail Extensions (MIME) 
    RFC 2424 - Content Duration MIME Header Definition
    Code Project上面有别人写的解码类
      

  5.   

    to:lemong(風之影)听你说的有道理啊!
    可是这个我实在没有做过,没有头绪,你能否具体说一点?
      

  6.   

    to:ChenLiuqing(没有心的鸟)你是不是研究过啊!能不能贴点代码?
      

  7.   

    to:ChenLiuqing(没有心的鸟)你是不是研究过啊!能不能贴点代码?
      

  8.   

    你怎么不使用jmail或其他的邮件控件来处理呢?
      

  9.   

    http://www.7880.com/Info/Article-500e1460.html 是个VB的
    我也在考虑这个问题,希望能给你帮助
      

  10.   

    /*解码*/
    private String deCode(String strSrc)
    {
    int start=strSrc.IndexOf("=?GB2312?");
    if (start==-1)
    {
    start=strSrc.IndexOf("=?gb2312?");
    }
    if(start>=0)
    {
    String strHead=strSrc.Substring(0,start);
    String strMethod=strSrc.Substring(start+9,1);
    strSrc=strSrc.Substring(start+11);
    int end=strSrc.IndexOf("?=");
    if (end==-1)
    {
    end=strSrc.Length;
    }
    String strFoot=strSrc.Substring(end+2,strSrc.Length-end-2);
    strSrc=strSrc.Substring(0,end);
    if(strMethod=="B")
    strSrc=strHead+deCodeB64(strSrc)+strFoot;
    else
    {
    if(strMethod=="Q")
    strSrc=strHead+deCodeQP(strSrc)+strFoot;
    else
    strSrc=strHead+strSrc+strFoot;
    }
    start=strSrc.IndexOf("=?GB2312?");
    if(start==-1)
    {
    start=strSrc.IndexOf("=?gb2312?");
    }
    if(start>=0)
    strSrc=deCode(strSrc);
    }
    return strSrc;
    }

    /*Base64 解码*/
    private String deCodeB64(String strSrc)
    {
    try 

    if(strSrc!="")
    {
    byte[] by=Convert.FromBase64String(strSrc); 
    strSrc=Encoding.Default.GetString(by);
    }

    catch(Exception ex) 
    {return ex.ToString();} 
    return strSrc;
    }

    /*Quoted-Printable 解码*/
    private String deCodeQP(String strSrc)
    { char ch, ch1, ch2;
    char[] hz;
    String strRet="";
    hz=strSrc.ToCharArray();
    for (int i=0;i<strSrc.Length;i++) 
    {
    ch = hz[i];
    if (ch == '=') 
    {
    i++;
    ch1 = hz[i];
    if (ch1 == '\n') continue;
    i++;
    ch2 = hz[i];
    int chint1,chint2;
    if (ch1>'9')
    {
    chint1=(ch1-'A'+10)*16;
    }
    else
    {
    chint1=(ch1-'0')*16;
    }
    if (ch2>'9')
    {
    chint2=ch1-'A'+10;
    }
    else
    {
    chint2=ch1-'0';
    }
    ch = Convert.ToChar(chint1 + chint2);
    }
    strRet += ch.ToString();
    }
    return strRet;
    }
      

  11.   

    to: yuanjie313(爱橘子的猪)多谢,不管能不能帮到我,都要谢谢你!
      

  12.   

    不错,我用了 yuanjie313(爱橘子的猪)的方法,可用,多谢
    当时以“?utf-8?”怎么取呀