protected override void OnMailing(ErrorMailEventArgs args) { var mail = args.Mail; var recipients = Recipients; if (recipients != null) { mail.To.AddRange(recipients.To); mail.CC.AddRange(recipients.Cc); mail.Bcc.AddRange(recipients.Bcc); } base.OnMailing(args); }
void ErrorMail_Mailing(object sender, ErrorMailEventArgs e) { // if async is set to true, this.Context will be null if (this.Context == null) { return; } if (this.Context.Request == null) { return; } // change email subject in certain conditions if (String.Equals(this.Context.Request.Headers["X-Requested-With"], "XMLHttpRequest", StringComparison.OrdinalIgnoreCase)) { e.Mail.Subject = "Ajax Error"; } if (this.Context.Request.InputStream == null) { return; } if (!this.Context.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase)) { return; } this.Context.Request.InputStream.Seek(0, SeekOrigin.Begin); var sr = new StreamReader(this.Context.Request.InputStream); var json = sr.ReadToEnd(); // will be empty string if InputStream was disposed var html = String.Format("<p>JSON:</p><pre style=\"background-color:#eee;\">{0}</pre>", json); e.Mail.Body = e.Mail.Body.Insert(e.Mail.Body.IndexOf("<pre id=\"errorDetail\">"), html); }
private static void ErrorEmailOnMailing(object sender, ErrorMailEventArgs e) { e.Mail.Subject = "Error on - " + "Main" + ": " + e.Mail.Subject; //Log.TraceError(e.Error.ToString()); }