public void Index() { try { int x, y, z; x = 5; y = 0; z = x / y; } catch (Exception ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); var log = new CreateLog(); log.GlobalPropertiesOfContAndMethodName(ex, actionName, controllerName); } }
void sendMail(IdentityMessage message) { #region formatter string text = string.Format("Please click on this link to {0}: {1}", message.Subject, message.Body); string html = "Please confirm your account by clicking this link: <a href='" + message.Body + "'>link</a><br/>"; html += HttpUtility.HtmlEncode(@"Or click on the copy the following link on the browser:" + message.Body); #endregion MailMessage msg = new MailMessage(); msg.From = new MailAddress(ConfigurationManager.AppSettings["Email"].ToString(), "*****@*****.**"); msg.To.Add(new MailAddress(message.Destination)); msg.Subject = message.Subject; msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(text, null, MediaTypeNames.Text.Plain)); msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html)); SmtpClient smtpClient = new SmtpClient("smtp-mail.outlook.com", 587); smtpClient.UseDefaultCredentials = false; NetworkCredential credentials = new NetworkCredential(ConfigurationManager.AppSettings["Email"].ToString(), ConfigurationManager.AppSettings["Password"].ToString()); smtpClient.Credentials = credentials; smtpClient.EnableSsl = true; try { smtpClient.Send(msg); } catch (Exception ex) { string actionName = "EmailException"; string controllerName = "SendEmail"; var log = new CreateLog(); log.GlobalPropertiesOfContAndMethodName(ex, actionName, controllerName); } smtpClient.Dispose(); }