请问ASP.net中如何实现发送E-mail的功能?

解决方案 »

  1.   

    用cdo组件发送 这样的帖子 太多了 楼主找找
      

  2.   

    有现成的email发送类,自己搜
      

  3.   

    推荐用jmail组件
    相关资料可以往上搜索一下
      

  4.   

    private void btnSend_Click(object sender, System.EventArgs e)
    {
      MailMessage myMail = new MailMessage();
      SmtpMail.SmtpServer="smtp.sina.com.cn";//发送服务器
      myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");//认证
      myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","xxx");//用户名
      myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","xxx");//密码
      myMail.To=txtTo.Text.Trim();//收信人
      myMail.From=txtFrom.Text.Trim();//寄信人
      myMail.Subject=txtTitle.Text.Trim();//主题
      myMail.Body=txtContent.Text;//内容
      myMail.BodyFormat=MailFormat.Text;//正文格式
      myMail.Priority=MailPriority.High;//优先级
      string result="";
      try
      {
        SmtpMail.Send(myMail);
        result="邮件发送成功!";
      }
      catch(Exception error)
      {
        result="邮件发送失败!"+error.Message;
      }
      finally
      {
        Response.Write("<script language='javascript'>window.alert('"+result+"');window.close();</script>");
      }
    }