100分求Jmail的ASP.net的C#实例,要求可直接导入项目可以运行!只要简单的,象新浪的哪个发邮件页面哪样的功能就可以

解决方案 »

  1.   

    jmail安装后就带有一个.net的例子..楼主打开安装目录看一下
      

  2.   

    using System;
    using jmail;public class Mail
    {
    private string _contentType = "text/html";//默认为html格式
    private string _userName;
    private string _passWord;
    private string _charSet = "GB2312";//默认为中文
    private string _serverAddress;
    private string _senderName;
    private string _sender;
    private byte _priority = 3;//默认邮件级别为3
    private string _subject;
    private string _body;
    private int _port = 110;//默认POP3端口为110
    private bool _logging = true;//默认记录日志
    private bool _silent = true;//这个属性用来控制是否屏蔽例外错误,默认是true,这样可以只返回false或者true
    private string _reciName;//收件人名称
    private string _reciAddress;//收件人地址
    private string PgpKey = "";
    private bool _isHtml = false; public bool IsHtml
    {
    get
    {
    if(this.ContenType == "text/html") 
    return true;
    else
    return true;
    }
    set{
    if(this.ContenType == "text/html") 
    this._isHtml = true;
    else
    this._isHtml = false;
    }
    } /// <summary>
    /// 收件人地址
    /// </summary>
    public string ReciAddress
    {
    get{return _reciAddress;}
    set{_reciAddress = value;}
    } /// <summary>
    /// 收件人名称
    /// </summary>
    public string ReciName
    {
    get{return _reciName;}
    set{_reciName = value;}
    } /// <summary>
    /// 是否启用日志
    /// </summary>
    public bool Logging
    {
    get{return _logging;}
    set{_logging = true;}
    } /// <summary>
    /// 是否屏蔽例外
    /// </summary>
    public bool Silent
    {
    get{return _silent;}
    set{_silent = value;}
    } /// <summary>
    /// 邮件格式
    /// </summary>
    public string ContenType
    {
    get{return _contentType;}
    set{_contentType = value;}
    } /// <summary>
    /// 邮件服务器用户名
    /// </summary>
    public string UserName
    {
    get{return _userName;}
    set{_userName = value;}
    } /// <summary>
    /// 邮件服务器密码
    /// </summary>
    public string PassWord
    {
    get {return _passWord;}
    set{_passWord = value;}
    } /// <summary>
    /// 邮件字符集
    /// </summary>
    public string CharSet
    {
    get{return _charSet;}
    set{_charSet = value;}
    } /// <summary>
    /// 邮件服务器地址
    /// </summary>
    public string ServerAddress
    {
    get{return _serverAddress;}
    set{_serverAddress = value;}
    } /// <summary>
    /// 发送者名称
    /// </summary>
    public string SenderName
    {
    get{return _senderName;}
    set{_senderName = value;}
    } /// <summary>
    /// 发送者地址
    /// </summary>
    public string Sender
    {
    get{return _sender;}
    set{_sender = value;}
    } /// <summary>
    /// 邮件紧急程度,1最高,5最慢,3为默认
    /// </summary>
    public byte Priority
    {
    get{return _priority;}
    set{_priority = value;}
    } /// <summary>
    /// 邮件主题
    /// </summary>
    public string Subject
    {
    get{return _subject;}
    set{_subject = value;}
    } /// <summary>
    /// 邮件内容
    /// </summary>
    public string Body
    {
    get{return _body;}
    set{_body = value;}
    } /// <summary>
    /// POP3端口
    /// </summary>
    public int Port
    {
    get{return _port;}
    set{_port = value;}
    } public bool SendMail()
    {
    jmail.Message objMail = new MessageClass();
    objMail.Charset = this.CharSet;
    objMail.Logging = this.Logging;
    objMail.Priority = this.Priority;
    objMail.From = this.Sender;
    objMail.FromName = this.SenderName;
    objMail.Silent = this.Silent;
    objMail.AddRecipient(this.ReciAddress,this.ReciName,this.PgpKey) ;
    objMail.Subject = this.Subject;
    objMail.MailServerUserName = this.UserName;
    objMail.MailServerPassWord  = this.PassWord;
    if(this.IsHtml)
    {
    objMail.HTMLBody = this.Body;
    }
    else
    {
    objMail.Body = this.Body;
    }
    return objMail.Send(this.ServerAddress,false);;
    }
    }
      

  3.   

    出错:
    c:\inetpub\wwwroot\Web\mail123.aspx.cs(222): 找不到类型或命名空间名称“objMail”(是否缺少 using 指令或程序集引用?)c:\inetpub\wwwroot\Web\mail123.aspx.cs(11): “System”的 using 指令以前在此命名空间中出现过c:\inetpub\wwwroot\Web\mail123.aspx.cs(221): 类型或命名空间名称“Message”在类或命名空间“Web.jmail”中不存在(是否缺少程序集引用?)
      

  4.   

    你需要引用jmail.dll这个组件阿
      

  5.   

    已经引用了我的代码是这样写的,还是出错using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using jmail;//namespace Web
    {
    /// <summary>
    /// mail123 的摘要说明。
    /// </summary>
    public class mail123 : System.Web.UI.Page
    {
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
    public class Mail
    {
    private string _contentType = "text/html";//默认为html格式
    private string _userName;
    private string _passWord;
    private string _charSet = "GB2312";//默认为中文
    private string _serverAddress;
    private string _senderName;
    private string _sender;
    private byte _priority = 3;//默认邮件级别为3
    private string _subject;
    private string _body;
    private int _port = 110;//默认POP3端口为110
    private bool _logging = true;//默认记录日志
    private bool _silent = true;//这个属性用来控制是否屏蔽例外错误,默认是true,这样可以只返回false或者true
     private string _reciName;//收件人名称
    private string _reciAddress;//收件人地址
    private string PgpKey = "";
    private bool _isHtml = false; public bool IsHtml
    {
    get
    {
    if(this.ContenType == "text/html") 
    return true;
    else
    return true;
    }
    set
    {
    if(this.ContenType == "text/html") 
    this._isHtml = true;
    else
    this._isHtml = false;
    }
    } /// <summary>
    /// 收件人地址
    /// </summary>
    public string ReciAddress
    {
    get{return _reciAddress;}
    set{_reciAddress = value;}
    } /// <summary>
    /// 收件人名称
    /// </summary>
    public string ReciName
    {
    get{return _reciName;}
    set{_reciName = value;}
    } /// <summary>
    /// 是否启用日志
    /// </summary>
    public bool Logging
    {
    get{return _logging;}
    set{_logging = true;}
    } /// <summary>
    /// 是否屏蔽例外
    /// </summary>
    public bool Silent
    {
    get{return _silent;}
    set{_silent = value;}
    } /// <summary>
    /// 邮件格式
    /// </summary>
    public string ContenType
    {
    get{return _contentType;}
    set{_contentType = value;}
    } /// <summary>
    /// 邮件服务器用户名
    /// </summary>
    public string UserName
    {
    get{return _userName;}
    set{_userName = value;}
    } /// <summary>
    /// 邮件服务器密码
    /// </summary>
    public string PassWord
    {
    get {return _passWord;}
    set{_passWord = value;}
    } /// <summary>
    /// 邮件字符集
    /// </summary>
    public string CharSet
    {
    get{return _charSet;}
    set{_charSet = value;}
    } /// <summary>
    /// 邮件服务器地址
    /// </summary>
    public string ServerAddress
    {
    get{return _serverAddress;}
    set{_serverAddress = value;}
    } /// <summary>
    /// 发送者名称
    /// </summary>
    public string SenderName
    {
    get{return _senderName;}
    set{_senderName = value;}
    } /// <summary>
    /// 发送者地址
    /// </summary>
    public string Sender
    {
    get{return _sender;}
    set{_sender = value;}
    } /// <summary>
    /// 邮件紧急程度,1最高,5最慢,3为默认
    /// </summary>
    public byte Priority
    {
    get{return _priority;}
    set{_priority = value;}
    } /// <summary>
    /// 邮件主题
    /// </summary>
    public string Subject
    {
    get{return _subject;}
    set{_subject = value;}
    } /// <summary>
    /// 邮件内容
    /// </summary>
    public string Body
    {
    get{return _body;}
    set{_body = value;}
    } /// <summary>
    /// POP3端口
    /// </summary>
    public int Port
    {
    get{return _port;}
    set{_port = value;}
    } public bool SendMail()
    {
    jmail.Message objMail = new MessageClass();
    objMail.Charset = this.CharSet;
    objMail.Logging = this.Logging;
    objMail.Priority = this.Priority;
    objMail.From = this.Sender;
    objMail.FromName = this.SenderName;
    objMail.Silent = this.Silent;
    objMail.AddRecipient(this.ReciAddress,this.ReciName,this.PgpKey) ;
    objMail.Subject = this.Subject;
    objMail.MailServerUserName = this.UserName;
    objMail.MailServerPassWord  = this.PassWord;
    if(this.IsHtml)
    {
    objMail.HTMLBody = this.Body;
    }
    else
    {
    objMail.Body = this.Body;
    }
    return objMail.Send(this.ServerAddress,false);;
    }
    } }
    }
      

  6.   

    我用你同样的东西,在我的项目当中建立了一个mail123类文件,编译的时候没有问题。  你是在调用SendMail函数的时候出现的错误,还是直接编译mail123的时候就已经有问题了?
      

  7.   

    http://www.cnblogs.com/goody9807/archive/2005/03/09/115367.html
      

  8.   

    http://www.aspemail.com/这里有个
    http://free.ys168.com/?goody9807
      

  9.   

    jmessage.AddRecipient(email ,"","");//接收人的邮件地址,姓名这句的三个参数是什么意思?
      

  10.   

    “/Web”应用程序中的服务器错误。
    --------------------------------------------------------------------------------The message was undeliverable. All servers failed to receive the message 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Runtime.InteropServices.COMException: The message was undeliverable. All servers failed to receive the message源错误: 
    行 63:  jmessage.MailServerUserName= "flcandclf" ;//发送者邮箱的用户名
    行 64:  jmessage.MailServerPassWord=  "flc198068" ;//发送者邮箱的密码
    行 65:  jmessage.Send("smtp.sohu.com",false)  ;//发送着邮箱的smtp服务器地址
    行 66:  //Response.Write("<script language='javascript'>alert('密码已成功发送到指定邮箱,请查收!');</script>");
    行 67:  jmessage.Close() ;
     源文件: c:\inetpub\wwwroot\web\webform777.aspx.cs    行: 65 堆栈跟踪: 
    [COMException (0x8000ffff): The message was undeliverable. All servers failed to receive the message]
       jmail.MessageClass.Send(String mailServer, Boolean enque) +0
       Web.WebForm777.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\web\webform777.aspx.cs:65
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain() +1277 
    --------------------------------------------------------------------------------
    版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
      

  11.   

    Message jmail=new Message();
    jmail.Silent=true;
    jmail.Logging=true;
    jmail.Charset="GB2312";
    jmail.ContentType="text/html";
    jmail.From="****";
    jmail.AddRecipient(****,"","");
    jmail.MailServerUserName="****";
    jmail.MailServerPassWord="****";
    jmail.Subject="索取密码";
    jmail.Body="你索取的新密码是:";
    if(jmail.Send("smtp.****.com",false))
    {
      //"恭喜您,发送邮件成功!";
    }
    else
    {
      //"发送邮件失败!";
    }
    jmail.Close();