关闭

用 ASP.Net 发Email

759人阅读 评论(0) 收藏 举报

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 System.Web.Mail; 

namespace PWDGet
{
 /// <summary>
 /// Summary description for passwordGet.
 /// </summary>
 public class passwordGet : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.Panel PanelError;
  protected System.Web.UI.WebControls.Panel panelMessage;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   if(!this.IsPostBack)   
   {    
    try
    {//send Email code
     MailMessage Mail=new MailMessage();

     Mail.From =strFromMan;
     Mail.To = strToMan;

     Mail.Subject =" ASC Wines Password Assistance";

     Mail.Body ="<html><head> <body>message</body></html>";
     Mail.BodyFormat=MailFormat.Html;
     
     Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
     Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","test");//这里填写你邮箱的用户名
     Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","ssbgroup");//你邮箱的密码

     SmtpMail.SmtpServer= "mail.ssbg.com.cn";  // 邮件服务器
 SmtpMail.Send(Mail);  

     //Response.Write("succeed!...");
    }
    catch
    {
     this.PanelError.Visible = true;
     this.panelMessage.Visible = false;
     
    }
   }
  }

  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion
 }
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:359279次
    • 积分:7221
    • 等级:
    • 排名:第3282名
    • 原创:250篇
    • 转载:126篇
    • 译文:2篇
    • 评论:41条
    最新评论
    日常工具