邮件收取客户端LumiSoft类库接收yahoo邮件的问题。
来源:互联网 发布:js统计下载次数 编辑:程序博客网 时间:2024/06/04 00:43
//开始循环取邮件数据 m_pImap.Fetch( false, IMAP_t_SeqSet.Parse("1:*"), new IMAP_t_Fetch_i[]{ new IMAP_t_Fetch_i_Envelope(), new IMAP_t_Fetch_i_Flags(), new IMAP_t_Fetch_i_InternalDate(), new IMAP_t_Fetch_i_Rfc822Size(), new IMAP_t_Fetch_i_Uid(), new IMAP_t_Fetch_i_Rfc822() }, this.m_pImap_Fetch_MessageItems_UntaggedResponse
上面的代码是直接收取邮件,包括头字段和邮件正文。
new IMAP_t_Fetch_i_Rfc822()注意,这句话是表示接收邮件的正文,而我经过测试,发现这段代码在接收yahoo邮箱的时候,邮件不能收取完全,因此在收取其他邮箱服务器的时候,可以采用上面的代码进行整体收件。
因此可以改成下面的这段代码
if(ip=="apple.imap.mail.yahoo.com") { //开始循环取邮件数据 m_pImap.Fetch( true, IMAP_t_SeqSet.Parse("1:*"), new IMAP_t_Fetch_i[]{ new IMAP_t_Fetch_i_Envelope(), new IMAP_t_Fetch_i_Flags(), new IMAP_t_Fetch_i_InternalDate(), new IMAP_t_Fetch_i_Rfc822Size(), new IMAP_t_Fetch_i_Uid(), //new IMAP_t_Fetch_i_Rfc822() }, this.m_pImap_Fetch_MessageItems_UntaggedResponseyahoo );
这里实际上就没有采用直接收取正文的方式,实际上,这里只是收取了头字段。那么应该在其他地方继续写收件的代码。
//调用读取邮件函数private void LoadMessage(long uid) { this.Cursor = Cursors.WaitCursor; try{ // Start fetching. m_pImap.Fetch( true, IMAP_t_SeqSet.Parse(uid.ToString()), new IMAP_t_Fetch_i[]{ new IMAP_t_Fetch_i_Rfc822() }, this.m_pImap_Fetch_Message_UntaggedResponse ); } catch(Exception x){ MessageBox.Show(this,"Error: " + x.ToString(),"Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }//邮件读取回调函数 private void m_pImap_Fetch_Message_UntaggedResponse(object sender,EventArgs<IMAP_r_u> e) { /* NOTE: All IMAP untagged responses may be raised from thread pool thread, so all UI operations must use Invoke. There may be other untagged responses than FETCH, because IMAP server may send any untagged response to any command. */ try{ if(e.Value is IMAP_r_u_Fetch){ IMAP_r_u_Fetch fetchResp = (IMAP_r_u_Fetch)e.Value; this.BeginInvoke(new MethodInvoker(delegate(){ try{ fetchResp.Rfc822.Stream.Position = 0; Mail_Message mime = Mail_Message.ParseFromStream(fetchResp.Rfc822.Stream); fetchResp.Rfc822.Stream.Dispose(); //m_pTabPageMail_MessagesToolbar.Items["save"].Enabled = true; //m_pTabPageMail_MessagesToolbar.Items["delete"].Enabled = true; //m_pTabPageMail_MessageAttachments.Tag = mime; foreach(MIME_Entity entity in mime.Attachments){ //ListViewItem item = new ListViewItem(); if(entity.ContentDisposition != null && entity.ContentDisposition.Param_FileName != null){ //item.Text = entity.ContentDisposition.Param_FileName; } else{ // item.Text = "untitled"; } //item.ImageIndex = 0; // item.Tag = entity; //m_pTabPageMail_MessageAttachments.Items.Add(item); } if(mime.BodyText != null){ // m_pTabPageMail_MessageText.Text = mime.BodyText; } try { //写入eml str stringhandle=new str();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#"; title=FilterSpecial(title); cstring mystring=new cstring(); title=mystring.ENCODE(title);title+=".eml";//写入eml文件 string filepro=Application.StartupPath+"\\data\\"+thisuser+"\\"+global_user+"\\"+folder+"\\"+title; FileStream fs = new FileStream(filepro, FileMode.Create);//文件名和路径 StreamWriter sw = new StreamWriter(fs); //开始写入 sw.Write(mime); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); } catch(Exception x) { } } catch(Exception x){ MessageBox.Show("Error: " + x.ToString(),"Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); } })); } } catch(Exception x){ MessageBox.Show("Error: " + x.ToString(),"Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); } }
也就是说,收取邮件头和邮件正文分开,这样就能收取包括yahoo在内的所有邮箱。代码是直接从我的工程文件里面拷出来的,作为参考,不能直接使用,但是保证是一定可以用的,更多问题可以联系我。
0 0
- 邮件收取客户端LumiSoft类库接收yahoo邮件的问题。
- 使用LumiSoft.Net收取邮件
- 使用LumiSoft.Net收取邮件(续)
- LumiSoft收取邮件(含邮件附件)
- LumiSoft收取邮件(含邮件附件)
- 用foxmail收取1G的yahoo邮件
- 收取邮件的工具类
- 使用 LumiSoft.Net.POP3.Client 接收邮件
- 使用 LumiSoft.Net.POP3.Client 接收邮件
- 使用 LumiSoft.Net.POP3.Client 接收邮件
- 基于Lumisoft.NET组件的POP3邮件接收和删除操作
- 基于Lumisoft.NET组件的POP3邮件接收和删除操作
- LumiSoft.Net 读取hotmail指定的邮件
- 使用 LumiSoft.Net.POP3.Client 接收邮件心得
- gmail邮件的pop收取
- 第三方邮件客户端收取163邮件问题(收邮件NO Select Unsafe Login. Please contact kefu解决办法)
- 用outlook接收YAHOO邮件设置
- Android采用javaMai收取邮件问题lpop3
- java jdbc
- 【实现】《算法概论》P18 第一章 数字的算法——除法(图1-2)
- checkBox
- 黑马程序员(七)1.5新特性动态代理
- JDK源码阅读之HashMap的实现
- 邮件收取客户端LumiSoft类库接收yahoo邮件的问题。
- 【二分查找算法】
- 单个uwsgi进程服务多个Django应用
- 道里云在云计算服务隐私安全保障方面的应用
- VC2012 对于还没有实现的类成员函数编译错误报告机制
- Linear Programming
- 2014-03-27工作日志:字符指针指向的字符串的输入、输出、求长度;将字符串与数字相连;
- IT技术笔试题(待续)
- Understanding Java Garbage Collection