William Lin 的专栏

Responsibility + chariness + bovine #1

用 ASP.Net 发Email

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
 }
}

阅读更多
想对作者说点什么? 我来说一句

Labview发送电子邮件

2017年08月24日 80KB 下载

没有更多推荐了,返回首页

不良信息举报

用 ASP.Net 发Email

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭