public void SendMail(MailSetting mailSetting, Mail mail) { try { if (mailSetting == null) { throw new ArgumentNullException("mailSetting can not be null."); } var client = new SmtpClient(mailSetting.Host, mailSetting.Port); client.EnableSsl = mailSetting.EnableSsl; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(mailSetting.UserName, mailSetting.Password); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Send(GetMailMessage(mailSetting, mail)); mail.IsSent = true; } catch (Exception ex) { LogHelper.AddSystemErrorLog(ex.ToString()); } }
protected void Application_Error(object sender, EventArgs e) { LogHelper.AddSystemErrorLog(Server.GetLastError().ToString()); }