1. //开始循环取邮件数据
  2. m_pImap.Fetch(
  3. false,
  4. IMAP_t_SeqSet.Parse("1:*"),
  5. new IMAP_t_Fetch_i[]{
  6. new IMAP_t_Fetch_i_Envelope(),
  7. new IMAP_t_Fetch_i_Flags(),
  8. new IMAP_t_Fetch_i_InternalDate(),
  9. new IMAP_t_Fetch_i_Rfc822Size(),
  10. new IMAP_t_Fetch_i_Uid(),
  11. new IMAP_t_Fetch_i_Rfc822()
  12. },
  13. this.m_pImap_Fetch_MessageItems_UntaggedResponse

上面的代码是直接收取邮件,包括头字段和邮件正文。

  1. new IMAP_t_Fetch_i_Rfc822()

注意,这句话是表示接收邮件的正文,而我经过测试,发现这段代码在接收yahoo邮箱的时候,邮件不能收取完全,因此在收取其他邮箱服务器的时候,可以采用上面的代码进行整体收件。

因此可以改成下面的这段代码

  1. if(ip=="apple.imap.mail.yahoo.com")
  2. {
  3. //开始循环取邮件数据
  4. m_pImap.Fetch(
  5. true,
  6. IMAP_t_SeqSet.Parse("1:*"),
  7. new IMAP_t_Fetch_i[]{
  8. new IMAP_t_Fetch_i_Envelope(),
  9. new IMAP_t_Fetch_i_Flags(),
  10. new IMAP_t_Fetch_i_InternalDate(),
  11. new IMAP_t_Fetch_i_Rfc822Size(),
  12. new IMAP_t_Fetch_i_Uid(),
  13. //new IMAP_t_Fetch_i_Rfc822()
  14. },
  15. this.m_pImap_Fetch_MessageItems_UntaggedResponseyahoo
  16. );
 

这里实际上就没有采用直接收取正文的方式,实际上,这里只是收取了头字段。那么应该在其他地方继续写收件的代码。

  1. //调用读取邮件函数
  2. private void LoadMessage(long uid)
  3. {
  4. this.Cursor = Cursors.WaitCursor;
  5. try{
  6. // Start fetching.
  7. m_pImap.Fetch(
  8. true,
  9. IMAP_t_SeqSet.Parse(uid.ToString()),
  10. new IMAP_t_Fetch_i[]{
  11. new IMAP_t_Fetch_i_Rfc822()
  12. },
  13. this.m_pImap_Fetch_Message_UntaggedResponse
  14. );
  15. }
  16. catch(Exception x){
  17. MessageBox.Show(this,"Error: " + x.ToString(),"Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
  18. }
  19. this.Cursor = Cursors.Default;
  20. }
  21. //邮件读取回调函数
  22. private void m_pImap_Fetch_Message_UntaggedResponse(object sender,EventArgs<IMAP_r_u> e)
  23. {
  24. /* NOTE: All IMAP untagged responses may be raised from thread pool thread,
  25. so all UI operations must use Invoke.
  26. There may be other untagged responses than FETCH, because IMAP server
  27. may send any untagged response to any command.
  28. */
  29. try{
  30. if(e.Value is IMAP_r_u_Fetch){
  31. IMAP_r_u_Fetch fetchResp = (IMAP_r_u_Fetch)e.Value;
  32. this.BeginInvoke(new MethodInvoker(delegate(){
  33. try{
  34. fetchResp.Rfc822.Stream.Position = 0;
  35. Mail_Message mime = Mail_Message.ParseFromStream(fetchResp.Rfc822.Stream);
  36. fetchResp.Rfc822.Stream.Dispose();
  37. //m_pTabPageMail_MessagesToolbar.Items["save"].Enabled = true;
  38. //m_pTabPageMail_MessagesToolbar.Items["delete"].Enabled = true;
  39. //m_pTabPageMail_MessageAttachments.Tag = mime;
  40. foreach(MIME_Entity entity in mime.Attachments){
  41. //ListViewItem item = new ListViewItem();
  42. if(entity.ContentDisposition != null && entity.ContentDisposition.Param_FileName != null){
  43. //item.Text = entity.ContentDisposition.Param_FileName;
  44. }
  45. else{
  46. // item.Text = "untitled";
  47. }
  48. //item.ImageIndex = 0;
  49. // item.Tag = entity;
  50. //m_pTabPageMail_MessageAttachments.Items.Add(item);
  51. }
  52. if(mime.BodyText != null){
  53. // m_pTabPageMail_MessageText.Text = mime.BodyText;
  54. }
  55. try
  56. {
  57. //写入eml
  58. str stringhandle=new str();
  59. string title=mime.From.ToString()+"#"+stringhandle.strlen(mime.Subject.ToString(),20)+"#"+mime.Date.ToString("yyyy年MM月dd日 HH时mm分")+"#"+(mime.BodyText.Length / (decimal)1000).ToString("f2") + " kb#";
  60. title=FilterSpecial(title);
  61. cstring mystring=new cstring();
  62. title=mystring.ENCODE(title);
  63. title+=".eml";
  64. //写入eml文件
  65. string filepro=Application.StartupPath+"\\data\\"+thisuser+"\\"+global_user+"\\"+folder+"\\"+title;
  66. FileStream fs = new FileStream(filepro, FileMode.Create);//文件名和路径
  67. StreamWriter sw = new StreamWriter(fs);
  68. //开始写入
  69. sw.Write(mime);
  70. //清空缓冲区
  71. sw.Flush();
  72. //关闭流
  73. sw.Close();
  74. fs.Close();
  75. }
  76. catch(Exception x)
  77. {
  78. }
  79. }
  80. catch(Exception x){
  81. MessageBox.Show("Error: " + x.ToString(),"Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
  82. }
  83. }));
  84. }
  85. }
  86. catch(Exception x){
  87. MessageBox.Show("Error: " + x.ToString(),"Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
  88. }
  89. }

也就是说,收取邮件头和邮件正文分开,这样就能收取包括yahoo在内的所有邮箱。代码是直接从我的工程文件里面拷出来的,作为参考,不能直接使用,但是保证是一定可以用的,更多问题可以联系我。

邮件收取客户端LumiSoft类库接收yahoo邮件的问题。的更多相关文章

  1. Python邮箱客户端编写之接收邮件操作

    Python的POP3类有很多方法来管理邮箱. 首先需要导入poplib库,import poplib POP3(server) 连接到邮箱服务器 user(username)将用户名发送至服务器,等 ...

  2. 一步一步从原理跟我学邮件收取及发送 2.邮箱的登录和绕不开的base64

    一步一步从原理跟我学邮件收取及发送 2.邮箱的登录和绕不开的base64 好了,经过本系列上一篇文章 "1.网络命令的发送",假设大家已经掌握了 email 电子邮件的命令发送的方 ...

  3. Java网络编程:QQ邮件发送客户端程序设计

    目录 一.目标介绍 1.认识SMTP(邮件传输协议) 2.POP3(邮件接收协议) 二.基于Base64编码邮箱及授权码 1.开通QQ邮箱SMTP/POP3服务 2.Java编写BASE64编码程序 ...

  4. Java实现QQ邮件发送客户端

    目录 一.前言:QQ邮件发送程序 二.封装SMTP操作 三.实现多线程接收 四.QQ邮件客户端界面设计 1.连接按钮 2.发送按钮 五.QQ邮件发送效果演示 六.总结 一.前言:QQ邮件发送程序 在上 ...

  5. C# 实现邮件收取发送功能

    .Net调用QQ邮箱发送邮件   话说网上发送邮件的代码很多,但是我由于不细心,导致拿别人的代码发送邮件老是失败,今天就说说几个要注意的地方吧!!! ? 1 2 3 4 5 6 7 8 9 10 11 ...

  6. .NET开发邮件发送功能的全面教程(含邮件组件源码)

    今天,给大家分享的是如何在.NET平台中开发“邮件发送”功能.在网上搜的到的各种资料一般都介绍的比较简单,那今天我想比较细的整理介绍下: 1)         邮件基础理论知识 2)         ...

  7. IMAP(Internet Mail Access Protocol,Internet邮件访问协议)以前称作交互邮件访问协议(Interactive Mail Access Protocol)。

    IMAP(Internet Mail Access Protocol,Internet邮件访问协议)以前称作交互邮件访问协议(Interactive Mail Access Protocol).IMA ...

  8. centos 邮件服务 腾讯企业邮箱(免费) 使用iRedmail 需要有公网的centos主机 发邮件协议:smtp 端口25 收邮件协议:pop3 端口110 iredmail安装配置 使用邮箱系统 第三十一节课

    centos   邮件服务  腾讯企业邮箱(免费) 使用iRedmail 需要有公网的centos主机 发邮件协议:smtp 端口25  收邮件协议:pop3 端口110  iredmail安装配置 ...

  9. php iamp 接收邮件,收取邮件,获取邮件列表

    每次想写的时候吧,提笔忘字.等到再次使用,又得想半天,,,,,好尴尬. 这次一边做一边写. 心得,程序员从菜鸟往老鸟转变的重要一步,学英语,看文档,在此我万分感谢鸟哥,,,,没他php哪有官方的中文注 ...

随机推荐

  1. $(").each 和$.each

    $(").each 这个是遍历dom树的,遍历数组的会报not afunction

  2. 无法在Web服务器上启动调试。

    Ⅰ x 操作超时 有关详细信息,请单击"帮助" x IIS--应用程序池--找到用到的程序池--回收   2 报这个错误的时候,我的IIS应用程序池只有一个>>> ...

  3. [No0000F2]ip安全监视器

    IPSec快速式策略 @echo off :again set num= set fastpolicyname= set issoft= set livetime= set fps= setlocal ...

  4. 相对定位和绝对定位 left和margin-left

    1.直接在css中设置left生效的前提是必须设置父容器position:absolute或relative,如果不设置则会以最近一个定位的父对象为参考点,.margin-left则不用设positi ...

  5. https://pypi.org/project/py-mysql2pgsql/

    https://packages.ubuntu.com/trusty/postgresql-server-dev-9.3 所以使用下面的命令即可安装python-dev: yum install py ...

  6. SQLAlchemy中时间格式化及将时间戳转成对应时间的方法-mysql

    https://blog.csdn.net/guoqianqian5812/article/details/80175866 方法很简答,都是借助于mysql数据库提供的函数将时间格式化方法 func ...

  7. python的数据库链接

    https://blog.csdn.net/canofy/article/details/83294330#-*-coding:utf-8-*-import MySQLdb #yum update p ...

  8. Nessus离线安装及升级插件

    最近做客户的内网主机漏洞扫描,申请了一台内网主机做扫描服务器,安装Nessus.由于客户严格限制内网主机不能开通外网访问权限,折腾了一下Nessus离线激活和离线更新漏洞插件,详细过程截图记录. 一. ...

  9. mysql windows开启客户端连接权限

    use mysql;  select 'host' from user where user='root';  update user set host = '%' where user ='root ...

  10. disruptor的并行用法

    实现EventFactory,在newInstance方法中返回,ringBuffer缓冲区中的对象实例:代码如下: public class DTaskFactory implements Even ...