以下是我从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
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
解决方案 »
- .net的cookie问题
- 求一个格式字符串
- 紧急求助啊!请大家进来帮帮小弟!
- 请问如何调用其它窗体中的对象
- DataGrid的问题
- 请教两个C#问题,中英文系统下的差异 及 在窗体上播放媒体。
- 北京安迈泽成的板卡 PCI7209那位大侠在C#里面用过,我的程序无法向卡端口写数据
- 保护级别限制是什么原因造成的啊?
- 安装了vs.net 2003 beta后,因为没有安msdn,使原来的vs.net2002中的Msdn也没法用了
- 在做.net演练时出现的错误,同志们请帮忙看看怎样解决,谢谢!
- 我该把数据库连接字符放在哪?
- wrox的不少书的代码怎么在网上这么难找到呀,c#线程手册的代码,哪位朋友给个连接,或发到我的邮箱里.
byte[] data = System.Convert.FromBase64String(base64);
MessageBox.Show(System.Text.Encoding.GetEncoding("gb2312").GetString(data));
2.根据不同的编码格式解码不同的内容(可能正文会分多个部分,各部分编码不同,如多媒体邮件)
RFC #733
RFC 2045 - Multipurpose Internet Mail Extensions (MIME)
RFC 2424 - Content Duration MIME Header Definition
Code Project上面有别人写的解码类
可是这个我实在没有做过,没有头绪,你能否具体说一点?
我也在考虑这个问题,希望能给你帮助
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;
}
当时以“?utf-8?”怎么取呀