这样做太累了。
建议在服务器上设置一个outlook 2003来定时接收,然后通过outlook编程来提取内容,这样就方便很多。

解决方案 »

  1.   

    留下你的郵箱,或你給我郵箱發消息:[email protected],我有一個完整的列子可以發給你﹗
      

  2.   

    private void btnRead_Click(object sender, System.EventArgs e)
    {
    string mPath,tmaph;
    mPath = ConfigurationSettings.AppSettings["UpFileDir"];
    tmaph =ConfigurationSettings.AppSettings["UpFileUrl"];
    try
    {
    // this.Label1.Visible = true;
    jmail.Message obj;
    jmail.POP3Class jpop = new POP3Class();
    jmail.Attachments atts;//建立附件集接口
    jmail.Attachment att;//建立附件接口
    jpop.Connect (this.ddlUserName.SelectedItem.ToString(),this.txtPassWord.Text,rdoit.SelectedItem.Text,110);  
    jpop.DownloadUnreadMessages();
    for(int i=0;i<jpop.Count;i++)
    {
    obj = jpop.Messages[i+1]; 
    obj.Charset = "gb2312";
    obj.Encoding = "Base64";
    obj.ContentType="text/html";
    obj.ISOEncodeHeaders = false;
    obj.ContentTransferEncoding = "base64";
    MailReceiveInfo info=new MailReceiveInfo(); 
    info.SendPeople =obj.From ;
    info.SendTime =obj.Date ;
    if(obj.Attachments.Count>0)
    {
    if (Directory.Exists(mPath) == false)
    { //若文件夹不存在,则创建
    DirectoryInfo dinfo = Directory.CreateDirectory(mPath);
    }
    atts = obj.Attachments;
    att = atts[0];
    if(File.Exists(mPath + att.Name))
    {
    File.Delete(mPath + att.Name);
    }
    att.SaveToFile(mPath + att.Name);//下载附件
    info.attachment = tmaph + att.Name;//附件内容
    // info.attachment = Server.MapPath("attachment/") + att.Name;
    // lblUserName.Text = mail.Name.ToString();//附件的名字
    }
    else
    {
    info.attachment ="";
    }
    info.Subject =obj.Subject;
    if(obj.Body==null)
    {
    info.Content = "";
    }
    else
    {
    info.Content =obj.Body;
    }
    info.ReceiveTime =System.DateTime.Now ;
    info.IsRead =false;
    DSKJ.Mail.BLL.Mail ail=new DSKJ.Mail.BLL.Mail();

    if(ail.Insert(info))
    {
    jpop.DeleteSingleMessage(i+1);     //删除服务器的邮件
    }  
    }
    jpop.Disconnect();//断开连接
    Response.Redirect("../Mail/ReceiveMailManage.aspx");
    }
    catch
    {
    Message("收信失败!请查看网络,再检查请填写信息是否正确!");
    }
    }
      

  3.   

    建议不要用openpop,邮件解码不是太好,个人感觉对邮件解码最完美的应该属outlook.
      

  4.   

    我现在有个新问题:如何用c#从eml文件中提取邮件附件
    最好有c#的源码!!
    ------------------
    我现在把接受的文件保存为eml形式的文件,作为备份.
    在系统要恢复备份时,要提取eml文件中附件,
    请问有c#的从eml中提取附件的代码吗?