⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendingmail.aspx

📁 东软内部材料(四)asp等相关的教学案例 
💻 ASPX
字号:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Mail" %>


<html>
<head>
<!--------------------------------------------------------------------------->

<script language="c#" runat="server">

  void Page_Load(Object Sender, EventArgs E)
  {
    SqlConnection	myConnection;
    string				ConnStr;
    int i;
    int x = 0;
    int y = 0;

    // set the connection details
    ConnStr = "Server=localhost; database=_pubs; UID=sa";

    try
    {
      myConnection = new SqlConnection(ConnStr);
      myConnection.Open();

      i = x / y;
		}
    catch (SqlException exSQL)
    {
      SendMail(exSQL.ToString());
		}
    catch (Exception ex)
    {
      SendMail(ex.ToString());
		}
		finally
		{
		}
	}

  void SendMail(string message)
  {
    MailMessage MyMessage = new MailMessage();

    MyMessage.To = "webmaster@yourcompany.com";
    MyMessage.From = "ASPApplication@yourcompany.com";
    MyMessage.Subject = "Unhandled ASP.NET Error";
    MyMessage.BodyFormat = MailFormat.Text;

    MyMessage.Body = message;

    SmtpMail.SmtpServer = "localhost";
    SmtpMail.Send(MyMessage);
  }
	
</script>


</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -