2 cnqylong cnqylong 于 2016.04.09 21:08 提问

Jmail4.4实现邮件接受,发现“邮件附件较大时(如40兆),接收邮件非常慢,求解决方法 8C
    public static jmail.POP3Class popMail;      //实例化POP3类对象
    public static jmail.Message mailMessage;    //实例化邮件对象
    public static jmail.Attachments atts;       //实例化邮件的附件集合
    public static jmail.Attachment att;         //实例化附件对象
    public static string strserver;             //存储邮件服务器
    public static string user;                  //存储用户登录邮箱的用户名
    public static string pwd;                   //存储用户登录邮箱的密码
            private void frmMain_Load(object sender, EventArgs e)
    {   
                    user = "。。。。。@139.com";
        pwd = "。。。。。";
        strserver = "pop.139.com";
        popMail = new jmail.POP3Class();
                                    if (popMail.Count != 0)
            {
                dgvEmailInfo.RowCount = popMail.Count;
                if (popMail != null)
                {
                    if (popMail.Count > 0)//当邮箱中存在邮件的情况下运行代码
                    {
                        for (int i = 1; i < popMail.Count; i++)
                        {


                            mailMessage = popMail.Messages[i];//**遇到大邮件时主要是这个过程耗时**间

                            //mailMessage.Charset = "GB2312";
                            if (mailMessage.From == user.Trim().ToLower())
                            {
                                dgvEmailInfo.Rows[i - 1].Cells[0].Value = "我";
                            }
                            else
                            {
                                dgvEmailInfo.Rows[i - 1].Cells[0].Value = mailMessage.From;
                            }
                            dgvEmailInfo.Rows[i - 1].Cells[1].Value = Base64Decode(mailMessage.Subject);
                            dgvEmailInfo.Rows[i - 1].Cells[2].Value = Base64Decode(mailMessage.Body);
                            dgvEmailInfo.Rows[i - 1].Cells[4].Value = mailMessage.Date.ToString();
                            if (popMail.Count >= 1 && i <= popMail.Count)
                            {
                                atts = mailMessage.Attachments;
                                if (atts.Count > 0)
                                {
                                    dgvEmailInfo.Rows[i - 1].Cells[3].Value = "附件下载";
                                }
                                else
                                {
                                    dgvEmailInfo.Rows[i - 1].Cells[3].Value = "无附件";
                                }
                            }
                        }
                    }
                }
            }
                             else
            {
                dgvEmailInfo.Rows.Clear();
            }

1个回答

caozhy
caozhy   Ds   Rxr 2016.04.10 06:03

这个传输的开销是必须的,或者你可以在服务器上解析邮件,只返回所需的数据。

cnqylong
cnqylong 求大神指导啊,给点具体信息
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!