高手请进!关于邮件接收解码!up有分!

lyb_abiandbel 2005-06-14 10:47:20
以下是我从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 <yuranccc_2003@163.com>; 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 <yuranccc_2003@163.com>; Tue, 14 Jun 2005 10:05:01 +0800 (CST)Date: Tue, 14 Jun 2005 10:03:43 +0800From: "lyb" <abiandbel@sohu.com>To: "yuranccc_2003" <yuranccc_2003@163.com>Subject: testX-mailer: Foxmail 5.0 [cn]Mime-Version: 1.0Content-Type: text/plain; charset="gb2312"Content-Transfer-Encoding: base64Message-Id: <20050614020501.D3BC700DF0A@smtp119.sohu.com>eXVyYW5jY2NfMjAwM6OsxPq6w6OhDQoNCgkgICAgICAgICAgICAgICAgICBhYWFhYQ0KDQqhoaGhoaGhoaGhoaGhoaGh1sINCsDxo6ENCiAJCQkJDQoNCqGhoaGhoaGhoaGhoaGhoaFseWINCqGhoaGhoaGhoaGhoaGhoaFhYmlhbmRiZWxAc29odS5jb20NCqGhoaGhoaGhoaGhoaGhoaGhoaGhMjAwNS0wNi0xNA0K

sohu:
+OK 1062 octetsReturn-Path: <yuranccc_2003@163.com>Delivered-To: abiandbel@mx59.mail.sohu.comReceived: from 163.com (unknown [220.181.31.172]) by sohumx08.sohu.com (Postfix) with SMTP id 9DBA0002797F for <abiandbel@sohu.com>; 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 <abiandbel@sohu.com>; 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" <yuranccc_2003@163.com>To: "abiandbel" <abiandbel@sohu.com>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: <20050614021015.9DBA0002797F@sohumx08.sohu.com>X-Sohu-Antivirus: 0YWJpYW5kYmVso6zE+rrDo6ENCg0KCQkJdGVzdHRlc3S6w7rDo6GjoQ0KDQqhoaGhoaGhoaGhoaGhoaGh1sINCsDxo6ENCiAJCQkJDQoNCqGhoaGhoaGhoaGhoaGhoaFseWINCqGhoaGhoaGhoaGhoaGhoaF5dXJhbmNjY18yMDAzQDE2My5jb20NCqGhoaGhoaGhoaGhoaGhoaGhoaGhMjAwNS0wNi0xNA0K
...全文
377 53 打赏 收藏 转发到动态 举报
写回复
用AI写文章
53 条回复
切换为时间正序
请发表友善的回复…
发表回复
caoyuechun 2005-07-07
  • 打赏
  • 举报
回复
不错,我用了 yuanjie313(爱橘子的猪)的方法,可用,多谢
当时以“?utf-8?”怎么取呀
siugwan 2005-06-24
  • 打赏
  • 举报
回复
mark
marxTen 2005-06-24
  • 打赏
  • 举报
回复
UP一下!
lyb_abiandbel 2005-06-24
  • 打赏
  • 举报
回复
怎么没有人啊!
happycat82 2005-06-23
  • 打赏
  • 举报
回复
up
lyb_abiandbel 2005-06-23
  • 打赏
  • 举报
回复
请高手帮帮忙啊!
lyb_abiandbel 2005-06-22
  • 打赏
  • 举报
回复
to: yuanjie313(爱橘子的猪)

多谢,不管能不能帮到我,都要谢谢你!
lyb_abiandbel 2005-06-22
  • 打赏
  • 举报
回复
up
lyb_abiandbel 2005-06-21
  • 打赏
  • 举报
回复
up
yuanjie313 2005-06-21
  • 打赏
  • 举报
回复
/*解码*/
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;
}
yuanjie313 2005-06-21
  • 打赏
  • 举报
回复
http://www.7880.com/Info/Article-500e1460.html 是个VB的
我也在考虑这个问题,希望能给你帮助
jinbingg 2005-06-20
  • 打赏
  • 举报
回复
up
StreamH 2005-06-20
  • 打赏
  • 举报
回复
呵呵,关注一下,好像挺难的
stlwj 2005-06-20
  • 打赏
  • 举报
回复
你怎么不使用jmail或其他的邮件控件来处理呢?
lyb_abiandbel 2005-06-20
  • 打赏
  • 举报
回复
期待高人解答
lyb_abiandbel 2005-06-20
  • 打赏
  • 举报
回复
这个问题有难度啊!
itoltgvi 2005-06-20
  • 打赏
  • 举报
回复
up
ghchen 2005-06-20
  • 打赏
  • 举报
回复
lyb_abiandbel 2005-06-20
  • 打赏
  • 举报
回复
up
lyb_abiandbel 2005-06-16
  • 打赏
  • 举报
回复
帮我看看啊!
加载更多回复(32)

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧