private static void Send(MvcMailMessage message) { try { message.Send(); } catch (Exception ex) { Logger.WriteEmergency(ex, ex.Message); } }
public ActionResult Register(CoupleUser CoupleUser) { if (ModelState.IsValid) { CoupleUser.Couple.User = CoupleUser.User; db.Couple.Add(CoupleUser.Couple); db.SaveChanges(); var email = new MvcMailMessage { Subject = "Confirmação de Email"}; email.To.Add(CoupleUser.User.Email); email.ViewName = "Welcome"; email.Send(); return RedirectToAction("SignIn", "User", CoupleUser.User); } else { return View("Create", CoupleUser.User); } }
private static void SendAsync(MvcMailMessage message) { try { var task = Task.Factory.StartNew(() => message.Send()); task.ContinueWith(t => { if (t.Exception == null) return; foreach (var innerEx in t.Exception.InnerExceptions) Logger.WriteEmergency(innerEx, innerEx.Message); }); } catch (Exception ex) { Logger.WriteEmergency(ex, ex.Message); } }