private void BtnSendResponse_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(meResponseBody.Text)) { try { var focusedMail = wevMails.GetFocusedRow() as TheMail; var responseMail = new TheMail(); responseMail.Body = meResponseBody.Text; responseMail.FromAddress = focusedMail.ToAddress; responseMail.FromDisplayName = $"ФрэдроКлиент"; responseMail.ToAddress = focusedMail.FromAddress; responseMail.ToDisplayName = focusedMail.FromDisplayName; responseMail.Subject = focusedMail.Subject; responseMail.ChachedEmailBoxId = focusedMail.ChachedEmailBoxId; _model.SendMail(responseMail); TwinkleMessageBox.ShowSucces("Письмо отправлено!"); meResponseBody.Text = ""; SetResponseBodyVisibility(false); } catch (Exception ex) { TwinkleMessageBox.ShowError($"Ответ не отправлен! {ex.Message}"); } } else { TwinkleMessageBox.ShowError("Нельзя отправить пустой ответ!"); } }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(model.Email); if (user == null && !(await UserManager.IsEmailConfirmedAsync(user.Id))) { // Don't reveal that the user does not exist or is not confirmed return(View("ForgotPasswordConfirmation")); } // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); MailModel mail = new MailModel(); mail.Subject = "Reset password!"; mail.Email = UserManager.FindById(user.Id).Email; var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); mail.Body = string.Format("Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); mail.SendMail(); return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } // If we got this far, something failed, redisplay form return(View(model)); }
public JsonResult SetBidWinner(int id) { BidModel.SetWinner(id); BidModel bid = BidModel.GetBidById(id).First(); MailModel mail = new MailModel(); mail.Subject = "Դուք հաղթել եք"; mail.Email = UserManager.FindById(bid.UserId).Email; var callbackUrl = Url.Action("Index", "Bid", new { id = id }, protocol: Request.Url.Scheme); mail.Body = string.Format(Resource.EmailConfirmationBid, callbackUrl); mail.SendMail(); return(Json(string.Format("Bid set as winner"), JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, PhoneNumber = model.Phone }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); UserViewModel userInfo = new UserViewModel(); userInfo.LastName = model.LastName; userInfo.Name = model.Name; userInfo.Nickname = model.Nickname; userInfo.Phone = model.Phone; userInfo.UserId = user.Id; int errorCode = userInfo.Save(); if (errorCode == 11) { ModelState.AddModelError("", "Nickname already exists"); return(View(model)); } // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); MailModel mail = new MailModel(); mail.Email = UserManager.FindById(user.Id).Email; mail.Subject = "Confirm Email"; mail.Body = "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"; mail.SendMail(); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public IActionResult OnPostSalvarDados() { Usuario usuario = HttpContext.Session.GetObjectFromJson <Usuario>("USUARIO"); if (usuario != null) { using (PrivacyContext context = new PrivacyContext()) { usuario.Ativo = false; usuario.DataCadastro = DateTime.Now; usuario.Login = usuario.Email; context.Usuario.Add(usuario); context.SaveChanges(); } string html = MailModel.ReturnBodyTemplate(); MailModel.Server = _configuration["Smtp:Server"]; MailModel.User = _configuration["Smtp:User"]; MailModel.Pass = _configuration["Smtp:Pass"]; MailModel.Port = _configuration["Smtp:Port"]; MailModel.EnableSSL = _configuration["Smtp:EnableSSL"]; html = html.Replace("{Titulo}", "Privacy - Ativação de conta"); html = html.Replace("{Subtitulo}", string.Format("Olá, {0} para concluir seu cadastro clique no link abaixo:", usuario.Nome)); html = html.Replace("{Texto}", "<a href=\"" + _configuration["Url"].ToString() + "/ActivateAccount?q=" + HttpUtility.UrlEncode(Criptography.Encrypt(usuario.IdUsuario.ToString())) + "\">Ativar Conta</a>"); MailModel.SendMail(_configuration["Smtp:User"].ToString(), usuario.Email, "Privacy | Ativação de Conta", html); usuario = null; return(new JsonResult(new { OK = true, Mensagem = Mensagem }, new Newtonsoft.Json.JsonSerializerSettings() { })); } else { return(new JsonResult(new { OK = false, Mensagem = "Falha ao salvar os dados!" }, new Newtonsoft.Json.JsonSerializerSettings() { })); } }