`
jackey25
  • 浏览: 108990 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

EML文件解析c#(以LumiSoft为代码参考)

阅读更多
解析EML文件,
1、首先需要解析header
/*3.1.  GENERAL DESCRIPTION
A message consists of header fields and, optionally, a body.
The  body  is simply a sequence of lines containing ASCII characters.  It is separated from the headers by a null line  (i.e.,  a line with nothing preceding the CRLF).
*/
即一个空行为header与body的分隔符

注意,若是解析成中文的话,需要UTF-8的编码
"\r\n"为换行
2、解析boundaryID
ParseBoundaryID(string headers),因此解析的是header。

/*
System.Text.Encoding enc = null;
            string encoding = "gb2312";
            enc = System.Text.Encoding.GetEncoding(encoding);
            enc.GetString(Convert.FromBase64String(test));
*/
这段代码,可以实现中文乱码的翻译。

邮件EML文件解析,附件存储,中文乱码解析,都做好了。用c#做的,用到了LumiSoft的开源代码。其实有空可以看看它的代码怎么做的,还是比较简单,复杂一些,需要把各种情况都考虑进去。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics