using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using jmail;public partial class receivemail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ReciveByJmail();
    }
    /**/
    /// <summary>
    /// 利用Jmail接收邮件
    /// </summary>
    private void ReciveByJmail()
    {
        /**/
        ///建立收邮件对象
        POP3Class popMail = new POP3Class();        /**/
        ///建立邮件信息接口
        jmail.Message mailMessage;        /**/
        ///建立附件集接口
        jmail.Attachments atts;        /**/
        ///建立附件接口
        jmail.Attachment att;        try
        {
            popMail.Connect("[email protected]", "388180123", "pop.163.com", 110);            /**/
            ///如果收到邮件
            if (0 < popMail.Count)
            {
                /**/
                ///根据取到的邮件数量依次取得每封邮件
                for (int i = 1; i <= popMail.Count; i++)
                {
                    /**/
                    ///取得一条邮件信息
                    mailMessage = popMail.Messages[i];                    /**/
                    ///取得该邮件的附件集合
                    atts = mailMessage.Attachments;                    /**/
                    ///设置邮件的编码方式                          
                    mailMessage.Charset = "GB2312";                    /**/
                    ///设置邮件的附件编码方式                         
                    mailMessage.Encoding = "Base64";                    /**/
                    ///是否将信头编码成iso-8859-1字符集                        
                    mailMessage.ISOEncodeHeaders = false;                    /**/
                    ///邮件的优先级                     
                    txtpriority.Text = mailMessage.Priority.ToString();                    /**/
                    ///邮件的发送人的信箱地址                      
                    txtSendMail.Text = mailMessage.From;                    /**/
                    ///邮件的发送人                     
                    txtSender.Text = mailMessage.FromName;                    /**/
                    ///邮件主题                   
                    txtSubject.Text = mailMessage.Subject;                    /**/
                    ///邮件内容                   
                    txtBody.Text = mailMessage.Body;                    /**/
                    ///邮件大小                        
                    txtSize.Text = mailMessage.Size.ToString();                    for (int j = 0; j < atts.Count; j++)
                    {
                        /**/
                        ///取得附件
                        att = atts[j];                        /**/
                        ///附件名称                              
                        string attname = att.Name;                        /**/
                        ///上传到服务器
                        att.SaveToFile("e:\\attFile\\" + attname);                    }                }
                panMailInfo.Visible = true;
                att = null;
                atts = null;
            }
            else
            {
                Response.Write("没有新邮件!");
            }            popMail.DeleteMessages();
            popMail.Disconnect();
            popMail = null;
        }
        catch
        {
            Response.Write("Warning!请检查邮件服务器的设置是否正确!");
        }
    }
}

解决方案 »

  1.   

    sorry,太着急了,连用户名和密码都贴出来了...
    代码本身没有问题,但是运行出现  Warning!请检查邮件服务器的设置是否正确!"
    这段代码应该怎么改popMail.Connect("[email protected]", "388180123", "pop.163.com", 110);
    前台就是用几个textbox接受数据.
      

  2.   

    bin里是Interop.jmail.dll会不会是dll的问题 我下的是4.4 是不是专业版不知道...
      

  3.   

    System.Runtime.InteropServices.COMException (0x8000FFFF): This function is not included in this version of jmail. 在 jmail.POP3Class.Connect(String Username, String Password, String Server, Int32 Port) 在 MailReceive.Button1_Click(Object sender, EventArgs e) sorry
      

  4.   

    多半是你所说的版本问题,
    据说非专业版本的不能这样popMail.Connect()使用
      

  5.   

    .aspx.cs:行号 31请检查邮件服务器的设置是否正确!
      

  6.   

    。net不是自己可以发邮件吗
    163现在支持pop3发邮件嘛    
      

  7.   

    你先确认你的帐户能不能支持SMTP和POP...163只有老用户(05前的吧,忘了)和收费用户才能使用SMTP和POP服务...