日期:2014-05-18  浏览次数:20563 次

ASP.net Jmail发邮件问题
using   System;
using   System.Data;
using   System.Configuration;
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   System.Web.Mail;
using   System.Web.Util;

public   partial   class   _Default   :   System.Web.UI.Page  
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {

        }
        protected   void   Button1_Click(object   sender,   EventArgs   e)
        {
                jmail.Message   Jmail   =   new   jmail.Message();

                DateTime   t   =   DateTime.Now;
                String   Subject   =   this.txtSubject.Text;
                String   Body   =   this.txtBody.Text;
                String   FromEmail   =   this.txtFromEmail.Text;
                String   ToEmail   =   this.txtToEmail.Text;

                Jmail.Silent   =   true;

                Jmail.Logging   =   true;

                Jmail.Charset   =   "GB2312 ";

                Jmail.ContentType   =   "text/html ";

                Jmail.AddRecipient(ToEmail,   " ",   " ");

                Jmail.From   =   FromEmail;

                Jmail.MailServerUserName   =   this.txtMSUserName.Text;

                Jmail.MailServerPassWord   =   this.txtMSPassword.Text;

                Jmail.Subject   =   Subject;

                Jmail.Body   =   this.txtBody.Text.ToString();

                Jmail.Send( "smtp.163.com ",   false);

                Jmail.Close();

        }
}


运行出来没有报错,也没有任何质疑的地方,点了确定按钮也没报错,但是我我到163的邮箱去看,就是没有邮件,为什么呢?

------解决方案--------------------
我用的时虚拟Smtp服务器(在自己机子上的)
jmail.Message message = new jmail.MessageClass();
message.From = "jmbkeyes@yahoo.com.cn ";
message.AddRecipient( "jmbkeyes@163.com ", " ", " ");

message.Subject = "你好 ";
message.Body = "dfdfdfdfdfdf ";
message.Charset = "GB2312 ";

message.AddAttachment( "c:\\cmd.txt ",true,null);