这是网上找的代码。在vs2010上运行就出现这个错误了。using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using LumiSoft.Net.Mime;
using LumiSoft.Net.POP3.Client; namespace WebApplication6
{
    public class pop
    {
        public List<Mime> GetEmails()
        {
            //需要首先设置这些信息 
            string pop3Server = "pop.qq.com";    //邮箱服务器 如:"pop.sina.com.cn";或 "pop.tom.com" 好像sina的比较快 
            int pop3Port = 110;          //端口号码   用"110"好使。最好看一下你的邮箱服务器用的是什么端口号 
            bool pop3UseSsl = false;
            string username = "*********";        //你的邮箱用户名 
            string password = "*********";      //你的邮箱密码 
            List<string> gotEmailIds = new List<string>();            List<Mime> result = new List<Mime>();
            using (POP3_Client pop3 = new POP3_Client())
            {
                try
                {
                    //与Pop3服务器建立连接 
                    pop3.Connect(pop3Server, pop3Port, pop3UseSsl);
                    //验证身份 
                    pop3.Authenticate(username, password, false);                    //获取邮件信息列表 
                    POP3_ClientMessageCollection infos = pop3.Messages;                    foreach (POP3_ClientMessage info in infos)
                    {
                        //每封Email会有一个在Pop3服务器范围内唯一的Id,检查这个Id是否存在就可以知道以前有没有接收过这封邮件 
                        if (gotEmailIds.Contains(info.UID))
                            continue;                        //获取这封邮件的内容 
                        byte[] bytes = info.MessageToByte();
                        //记录这封邮件的Id 
                        gotEmailIds.Add(info.UID);                        //解析从Pop3服务器发送过来的邮件信息 
                        Mime mime = Mime.Parse(bytes);                        result.Add(mime);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
            return result;
        } 
    }
}求各路大神来瞄一眼邮件lumisoft

解决方案 »

  1.   

    这是错误提示。纠结死了:
    “/”应用程序中的服务器错误。Invalid field name '<html xmlns="http:'. A field name MUST be composed of printable US-ASCII characters (i.e.,characters that have values between 33 and 126, inclusive),except colon.说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Exception: Invalid field name '<html xmlns="http:'. A field name MUST be composed of printable US-ASCII characters (i.e.,characters that have values between 33 and 126, inclusive),except colon.源错误: 
    行 57:                 catch (Exception ex)
    行 58:                 {
    行 59:                     throw new Exception(ex.Message);
    行 60:                 }
    行 61:             }源文件: H:\NetProject\WebApplication1\WebApplication6\pop.cs    行: 59 堆栈跟踪: 
    [Exception: Invalid field name '<html xmlns="http:'. A field name MUST be composed of printable US-ASCII characters (i.e.,characters that have values between 33 and 126, inclusive),except colon.]
       WebApplication6.pop.GetEmails() in H:\NetProject\WebApplication1\WebApplication6\pop.cs:59
       WebApplication6.WebForm1.Page_Load(Object sender, EventArgs e) in H:\NetProject\WebApplication1\WebApplication6\WebForm1.aspx.cs:20
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
       System.Web.UI.Control.OnLoad(EventArgs e) +92
       System.Web.UI.Control.LoadRecursive() +54
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.18033