Exemplo n.º 1
0
 private void SendEmail()
 {
     var mail = ExceptionEmailConfigs.ConfigEntity;
     var smtp = new SmtpMail(mail.LoginName, mail.LoginPwd, mail.SendMail, "Farseer.Net 运行异常记录", mail.SmtpServer, 0, mail.SmtpPort);
     var body = new StringBuilder();
     body.AppendFormat("<b>发现时间:</b> {0}<br />", CreateAt.ToString("yyyy年MM月dd日 HH:mm:ss"));
     body.AppendFormat("<b>程序文件:</b> <u>{0}</u> <b>第{1}行</b> <font color=red>{2}()</font><br />", FileName, LineNo, MethodName);
     body.AppendFormat("<b>错误消息:</b><font color=red>{0}</font><br />", Message);
     smtp.Send(mail.EmailAddress, string.Format("{0}:警告!数据库异常:{1}", DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss"), Message), body.ToString());
 }
 /// <summary> 发送邮件 </summary>
 private void SendEmail()
 {
     var mail = ExceptionEmailConfigs.ConfigEntity;
     var smtp = new SmtpMail(mail.LoginName, mail.LoginPwd, mail.SendMail, "Farseer.Net SQL异常记录", mail.SmtpServer, 0, mail.SmtpPort);
     var body = new StringBuilder();
     body.AppendFormat("<b>发现时间:</b> {0}<br />", CreateAt.ToString("yyyy年MM月dd日 HH:mm:ss"));
     body.AppendFormat("<b>程序文件:</b> <u>{0}</u> <b>第{1}行</b> <font color=red>{2}()</font><br />", FileName, LineNo, MethodName);
     
     switch (CmdType)
     {
         case CommandType.StoredProcedure: body.AppendFormat("<b>存储过程:</b> {0}<br />", Name); break;
         case CommandType.Text: body.AppendFormat("<b>表视图名:</b> {0}<br />", Name); body.AppendFormat("<b>Sql语句:</b> {0}<br />", Sql); break;
     }
     
     body.AppendFormat("<b>Sql参数:</b><br />");
     SqlParamList.ForEach(o => body.AppendFormat("{0} = {1}<br />", o.Name, o.Value));
     body.AppendFormat("<b>错误消息:</b><font color=red>{0}</font><br />", Message);
     smtp.Send(mail.EmailAddress, string.Format("{0}:警告!数据库异常:{1}", DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss"), Message), body.ToString());
 }