pop协议,2.0有类库的,直接调用就行了。

解决方案 »

  1.   

     protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                                  
            }
        }
       
        string content = "asdfasdffd";
        protected void Button4_Click(object sender, EventArgs e)
        {
            HttpPostedFile file = this.FileUpload1.PostedFile;
            int filelength = file.ContentLength;
            string filetype = file.ContentType;
            if (filelength == 0)
            {
                Response.Write("上传控件!=空");
            }
            else
            {
                string fullfileName = this.FileUpload1.PostedFile.FileName;
                string filename = fullfileName.Substring(fullfileName.LastIndexOf("\\") + 1);
     
                SendMai("服务器地址如:127.2.3.6", "用户名", "地址", "发送的邮箱", "接受者邮箱", "标题", 内容, fullfileName);
                        //阿里商务密码找回信息    标题    content内容
            }
        }
        public static void SendMail(string strSmtpServer, string UserName, string Password, string strFrom, string strto, string strSubject, string strBody, string strFileName)
        {
            //生成一个 使用SMTP发送邮件的客户端对象
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(strSmtpServer);        //表示以当前登录用户的默认凭据进行身份验证
            client.UseDefaultCredentials = true;
            //包含用户名和密码
            client.Credentials = new System.Net.NetworkCredential(UserName, Password);        //指定如何发送电子邮件。
            //Network                      电子邮件通过网络发送到 SMTP 服务器。  
            //PickupDirectoryFromIis       将电子邮件复制到挑选目录,然后通过本地 Internet 信息服务 (IIS) 传送。  
            //SpecifiedPickupDirectory     将电子邮件复制到 SmtpClient.PickupDirectoryLocation 属性指定的目录,然后由外部应用程序传送。          client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;        //建立邮件对象 
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(strFrom, strto, strSubject, strBody);
            string a = "[email protected],[email protected]";
            string []js = a.Split(',');
            int y = Convert.ToInt32(js.Length.ToString());
            if (js[y-1] == "")
            {
                for (int i = 0; i < js.Length - 1; i++)
                {
                    message.To.Add(js[i]);
                }
            }
            else
            {
                for (int i = 0; i < js.Length; i++)
                {
                    message.To.Add(js[i]);
                }
            }
            
                    //定义邮件正文,主题的编码方式
            message.BodyEncoding = System.Text.Encoding.GetEncoding("gb2312");
            message.SubjectEncoding = System.Text.Encoding.GetEncoding("gb2312");        //获取或设置一个值,该值指示电子邮件正文是否为 HTML。 
            message.IsBodyHtml = false;        //指定邮件优先级        message.Priority = System.Net.Mail.MailPriority.Normal;        //添加附件
            //System.Web.Mail.MailAttachment mailAttachment = new System.Web.Mail.MailAttachment(@"F://baihe.txt");
            if (strFileName != "" && strFileName != null)
            {
                Attachment data = new Attachment(strFileName);
                message.Attachments.Add(data);           
                
            }
            //发件人身份验证,否则163 发不了
            client.Credentials = new System.Net.NetworkCredential(strFrom, Password);
            //发送
            client.Send(message);
        }
        public static string Encrypt(string sPassword)
        {
            byte[] clearBytes = new UnicodeEncoding().GetBytes(sPassword);
            byte[] hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
            return BitConverter.ToString(hashedBytes);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            //msg.To.Add("[email protected]");
            msg.To.Add("[email protected]");
            /* 
             * msg.To.Add("[email protected]"); 
             * msg.To.Add("[email protected]"); 
             * msg.To.Add("[email protected]");可以发送给多人 
             */
            //msg.CC.Add("[email protected]");
            /* 
             * msg.CC.Add("[email protected]"); 
             * msg.CC.Add("[email protected]");可以抄送给多人 
             */
            msg.From = new MailAddress("[email protected]", "ali", System.Text.Encoding.UTF8);
            /* 上面3个参数分别是发件人地址(可以随便写),发件人姓名,编码*/
            msg.Subject = this.TextBox1.Text;//邮件标题             
            msg.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码 
            msg.Body = this.TextBox2.Text; ;//邮件内容 
            msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码 
            msg.IsBodyHtml = false;//是否是HTML邮件 
            msg.Priority = MailPriority.High;//邮件优先级         SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("mail.alishangwu.com", "801226");
            //上述写你的GMail邮箱和密码 
            client.Port = 587;//Gmail使用的端口 
            client.Host = "[email protected]";
            client.EnableSsl = true;//经过ssl加密 
            object userState = msg;
            //try
            //{
                client.SendAsync(msg, userState);
                //简单一点儿可以client.Send(msg); 
                Response.Write("发送成功");
            //}
            //catch (System.Net.Mail.SmtpException ex)
            //{
                //Response.Write(ex.Message);
            //}     }
    把分都给我
      

  2.   

    发邮件的两种方法以及收邮件的方法见我blog:http://www.cnblogs.com/ustbwuyi/archive/2007/05/28/762581.html
      

  3.   

    你用的什么pop服务器?
    把你代码贴出来看看....
      

  4.   

    2.0的邮件类相当简单
    /// <summary>
            /// 发送邮件
            /// </summary>
            /// <param name="mail"></param>
            /// <param name="password"></param>
            /// <returns></returns>
            public static void SendMail(string mail, string subject, string body)
            {
                MailMessage mailObj = new MailMessage();
                System.Net.Mail.SmtpClient client = new SmtpClient(@"smtp.163.com");            client.UseDefaultCredentials = false;
                client.Credentials = new System.Net.NetworkCredential(@"emailname", @"emailpassword");
                client.DeliveryMethod = SmtpDeliveryMethod.Network;            try
                {
                    System.Net.Mail.MailMessage message = new MailMessage(@"[email protected]", mail, subject, body);                message.BodyEncoding = System.Text.Encoding.UTF8;
                    message.IsBodyHtml = true;                client.Send(message);
                }
                catch
                { }
            }你拿掉try 调试下,注意杀毒软件可能会阻挡 w3p发邮件