public ActionResult SendMails() { AccountVM acc = new AccountVM(); BorrowingVM bor = new BorrowingVM(); BookVM book = new BookVM(); List <Book> books = book.Get_list(); List <Account> accounts = acc.Get_list(); List <Borrowing> borrows = bor.Get_list(); var emails = from b in books from o in borrows from a in accounts where o.BookID == b.BookID && a.AccountID == o.ReaderID && o.Returned == false && o.Return_date < DateTime.Now select new { a.Email, b.Title }; GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); Parallel.ForEach(emails, e => { mailer.ToEmail = e.Email; mailer.Subject = "BIBLIOTEKA - Zwrot książki"; mailer.Body = "Prosimy o zwrot książki '" + e.Title + "' !"; mailer.IsHtml = true; mailer.Send(); }); ViewBag.Mails1 = "Wysłano próśb " + emails.Count(); var emails1 = from b in books from o in borrows from a in accounts where o.BookID == b.BookID && a.AccountID == o.ReaderID && o.Returned == false && o.Return_date.Date == DateTime.Now.Date.AddDays(1) select new { a.Email, b.Title }; Parallel.ForEach(emails, e => { mailer.ToEmail = e.Email; mailer.Subject = "BIBLIOTEKA - Przypomnienie o zwrocie książki!"; mailer.Body = "Został jeden dzień do zwrotu książki '" + e.Title + "' ! Po upływie czasu kara zastanie naliczona!"; mailer.IsHtml = true; mailer.Send(); }); ViewBag.Mails2 = "Wysłano przypomnień " + emails1.Count(); return(View("Admin")); }
public async Task <ActionResult> AddEmail(AddEmailViewModel model) { if (ModelState.IsValid) { var userEmail = User.Identity.GetUserId(); var user = UserManager.FindById(userEmail); user.Email = model.Email; IdentityResult result = await UserManager.UpdateAsync(user); if (result.Succeeded) { var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = model.Email; mailer.Subject = "Вітаю, " + user.UserName + "!"; mailer.Body = "Пыдтвердыть вашу електронну адресу, перейшовши по посиланню <a href=\"" + callbackUrl + "\">Підтвердити</a>."; mailer.IsHtml = true; mailer.Send(); return(View("DisplayEmail")); } } return(View(model)); }
public ActionResult SendEmail(string header, string body) { int result = 0; try { GMailer.GmailUsername = "******"; GMailer.GmailPassword = ""; GMailer mailer = new GMailer(); List <DataAccessLayer.Entities.Client> layerClientList = ClientUtils.GetAllClients(); List <Client> clientList = Mappings.MappingDtos.EntityClientToModelClientAsList(layerClientList); mailer.Subject = header; mailer.Body = body; mailer.IsHtml = true; foreach (var item in clientList) { mailer.ToEmail = item.Email; mailer.Send(); } result = 1; } catch (Exception) { result = 0; } return(RedirectToAction("SendEmailResult", new { id = result })); }
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 http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = $"{user.Email}"; mailer.Subject = "Reset Password"; mailer.Body = "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"; mailer.IsHtml = true; mailer.Send(); return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult ForgetPassword(FormCollection formCollection) { var Email = Request["Email"].ToString(); if (Email == null) { Email = formCollection["Email"].ToString(); } var user = new UserMaster(); user = _userService.Get().Where(u => u.Email == Email).FirstOrDefault(); if (user == null) { ViewData["Error"] = "Email does not exist"; return(RedirectToAction("ForgetPassword")); } GMailer.GmailUsername = ""; GMailer.GmailPassword = ""; GMailer mailer = new GMailer(); mailer.ToEmail = user.Email; mailer.Body = PopulateBody(user); mailer.IsHtml = true; mailer.Send(); return(View()); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByEmailAsync(model.Email); if (user == null) { return(View("ForgotPasswordConfirmation")); } //Token Provider //var provider = new DpapiDataProtectionProvider("UsedGoodApp"); //UserManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(provider.Create("UsedGoodToken")); string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); //await UserManager.SendEmailAsync(user.Id, "Сброс пароля", // "Для сброса пароля, перейдите по ссылке <a href=\"" + callbackUrl + "\">сбросить</a>"); GMailer mailer = new GMailer(); mailer.ToEmail = model.Email; mailer.Subject = "Сброс пароля"; mailer.Body = "Ссылка для сброса пароля : <a href =\"" + callbackUrl + "\">" + callbackUrl + "</a> "; mailer.IsHtml = true; mailer.Send(); return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } return(View(model)); }
public ActionResult GenerateReport(Report r, String selectedID) { if (ModelState.IsValid) { r.SendDate = DateTime.Now; var id = int.Parse(Session["UserID"].ToString()); User first = db.Users.Where(x => x.UserID == id).FirstOrDefault(); Staff f = db.Staffs.Where(x => x.EMail == first.EMail).FirstOrDefault(); r.SenderID = first.UserID; r.ReceiverID = Convert.ToInt32(selectedID); db.Reports.Add(r); db.SaveChanges(); User u = db.Users.Where(x => x.UserID == r.ReceiverID).FirstOrDefault(); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = u.EMail; mailer.Subject = r.Subject; mailer.Body = r.Body; mailer.IsHtml = true; mailer.Send(); TempData["Success"] = "Your report has been sent."; return(RedirectToAction("Index", "Staff")); } return(View()); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByEmailAsync(model.Email); if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id))) { // Не показывать, что пользователь не существует или не подтвержден return(View("ForgotPasswordConfirmation")); } // Дополнительные сведения о том, как включить подтверждение учетной записи и сброс пароля, см. по адресу: http://go.microsoft.com/fwlink/?LinkID=320771 // Отправка сообщения электронной почты с этой ссылкой string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = model.Email; mailer.Subject = "Hey" + user.UserName + "! Do you forgot your passwrod???"; mailer.Body = "Сбросьте ваш пароль, щелкнув <a href=\"" + callbackUrl + "\">здесь</a>"; mailer.IsHtml = true; mailer.Send(); return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } // Появление этого сообщения означает наличие ошибки; повторное отображение формы return(View(model)); }
public void sendVerifyCompanyEmail(Seller p) { GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = "*****@*****.**"; mailer.Subject = "ADMINISTRATOR INPUT REQUIRED"; mailer.Body = "Hello Admin" + Environment.NewLine + Environment.NewLine + "A new user has registered to be a seller on the EthnoBotanicalsIreland website" + Environment.NewLine + Environment.NewLine + "Please navigate to 'Manage Sellers tab to verify their details." + Environment.NewLine + "Once you change the sellers's value 'Verified' to 'True', the seller will be listed on the website as a Seller." + Environment.NewLine + Environment.NewLine + "The seller has entered the following details:" + Environment.NewLine + Environment.NewLine + Environment.NewLine + "Seller Name: " + p.FirstName + " " + p.LastName + Environment.NewLine + "Company About: " + p.About + Environment.NewLine + "Company Description: " + p.Description + Environment.NewLine + "Address Line 1: " + p.AddressLine1 + Environment.NewLine + "Address Line 2: " + p.AddressLine2 + Environment.NewLine + "Address Line 3: " + p.AddressLine3 + Environment.NewLine + "PostCode: " + p.PostCode + Environment.NewLine + "City: " + p.City + Environment.NewLine + "Country: " + p.Country + Environment.NewLine + "Email: " + p.Email + Environment.NewLine + "Company Mobile: " + p.Mobile + Environment.NewLine; mailer.IsHtml = false; mailer.Send(); }
public ActionResult ForgotPassword(User s) { var u = db.Users.Where(x => x.EMail == s.EMail).FirstOrDefault(); if (u == null) { ModelState.AddModelError("", "Such user cannot be found."); return(View()); } else { PassReset p = new PassReset(); p.AutID = Guid.NewGuid().ToString(); p.isAvaliable = true; p.EMail = u.EMail; p.UserID = u.UserID; db.PassResets.Add(p); db.SaveChanges(); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = u.EMail; mailer.Subject = "Password Reset"; mailer.Body = "A request to reset your password has been sent. <br> Please enter the code below to Change Password page to Change your Password. <br> <a href='localhost.com/Account/ChangePassword'>verify</a> Authentication Code :" + p.AutID; mailer.IsHtml = true; mailer.Send(); ViewBag.Message = "A confirmation mail has been sent to you."; // return RedirectToAction("Index", "Home"); } return(View()); }
public JsonResult RegPrj(PROJECT Project, List <PROJECT_PLAN> Plans, List <KPI> KPIs) { int result = 0; PlanManager plan = PlanManager.GetInstance(); ProjectManager prj = ProjectManager.GetInstance(); KpiManager km = KpiManager.GetInstance(); EmployeeManager em = EmployeeManager.GetInstance(); IdeaManager idea = IdeaManager.GetInstance(); string existID = prj.IsExist(Project.IDEA_ID); if (string.IsNullOrEmpty(existID)) { // generate id if (string.IsNullOrWhiteSpace(Project.IDEA_ID)) { Project.IDEA_ID = idea.GenerateId(); idea.Insert(Project.EMP_ID, Project.IDEA_TITLE, Project.BACKGROUND, "", ""); } result = prj.InsertProject(Project); if (result > 0) { foreach (var p in Plans) { plan.InsertPlan(Project.IDEA_ID, p.PLAN_CONTENTS, p.PLAN_DATE); } foreach (var kpi in KPIs) { km.InsertKPI(Project.IDEA_ID, kpi.PRJ_MONTH, kpi.TARGET_VALUE); } try { var emails = em.GetListEmail(); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.Subject = "[Project Management - New project uploaded]"; mailer.Body = " Employee " + Project.EMP_ID + " Has uploaded a project: " + Project.IDEA_TITLE + ".<br> Please check it out at<br> <a href='http://172.25.215.17/idea'>Project Management</a>"; mailer.IsHtml = true; foreach (var email in emails) { mailer.ToEmail = email.EMAIL.Trim(); mailer.Send(); } } catch { return(Json(result)); } } } else { } return(Json(result)); }
// GET: Login public ActionResult SendResetEmail(string email) { Random rand = new Random(); string key = ""; int i = 0; for (i = 0; i < 16; i++) { int[] randoms = new int [] { rand.Next(48, 58), rand.Next(65, 91), rand.Next(97, 123) }; int rand_indx = rand.Next(0, 3); int curr_byte = randoms[rand_indx]; char c = (char)curr_byte; key += c; } var urlBuilder = new System.UriBuilder(Request.Url.AbsoluteUri) { Path = Url.Action("ResetPassword", "Login"), Query = null, }; Uri uri = urlBuilder.Uri; string url = urlBuilder.ToString(); String m = "<a href='" + url + "?key=" + key + "'>לחץ כאן להמשך איפוס סיסמא</a>"; GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>"; GMailer mailer = new GMailer(); mailer.ToEmail = email; mailer.Subject = "מערכת ניהול מכרזים - איפוס סיסמא"; mailer.Body = string.Format(body, "*****@*****.**", "מערכת לניהול מכרזים, לא להגיב!", m); mailer.IsHtml = true; mailer.Send(); bool exist = false; foreach (String s in LoginController.email_key.Keys) { if (s.CompareTo(email) == 0) { exist = true; } } if (exist) { LoginController.email_key.Remove(email); } LoginController.email_key.Add(email, key); return(Json("Sent", JsonRequestBehavior.AllowGet)); }
private void configSendGmail(IdentityMessage message) { GMailer.GmailUsername = ConfigurationManager.AppSettings["mailAccount"]; GMailer.GmailPassword = ConfigurationManager.AppSettings["mailPassword"]; GMailer mailer = new GMailer(); mailer.ToEmail = message.Destination; mailer.Subject = message.Subject; mailer.Body = message.Body; mailer.IsHtml = true; mailer.Send(); }
public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var ctoken = await _userManager.GenerateEmailConfirmationTokenAsync(user); var token_link = Url.Action("ConfirmEmail", "Account", new { userid = user.Id, token = ctoken }, protocol: HttpContext.Request.Scheme); ViewBag.token = token_link; ViewBag.emailNotify = "A confirmation mail has been sent to your email address!"; GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = user.Email; mailer.Subject = "Verify your email id"; mailer.Body = "Thanks for Registering your account.<br> please verify your email id by clicking the link below: <br>" + token_link; mailer.IsHtml = true; mailer.Send(); //var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); //var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); //await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl); await _signInManager.SignInAsync(user, isPersistent : false); _logger.LogInformation("User created a new account with password."); //return RedirectToLocal(returnUrl); return(View("~/Views/Account/EmailConfirmationSent.cshtml")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public JsonResult RegIdea(IDEA idea, string division, string department, int action) { EmployeeManager em = EmployeeManager.GetInstance(); IdeaManager ideaManager = IdeaManager.GetInstance(); int affectedRows = 0; if (action == 0) { affectedRows = ideaManager.Insert(idea.EMP_ID, idea.IDEA_TITLE, idea.DETAIL, idea.QUANTITATIVE, idea.QUALITATIVE); if (affectedRows > 0) { try { var emails = em.GetListEmail(); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.Subject = "[Project Management - New idea uploaded]"; mailer.Body = " Employee " + idea.EMP_ID + " Has uploaded an idea: " + idea.IDEA_TITLE + ".<br> Please check it out at<br> <a href='http://172.25.215.17/idea'>Project Management</a>"; mailer.IsHtml = true; foreach (var email in emails) { mailer.ToEmail = email.EMAIL.Trim(); mailer.Send(); } } catch { return(Json(affectedRows)); } } } else { affectedRows = ideaManager.Update(idea.ID, idea.EMP_ID, idea.IDEA_TITLE, idea.DETAIL, idea.QUANTITATIVE, idea.QUALITATIVE); } if (!string.IsNullOrWhiteSpace(division)) { em.UpdateDivision(idea.EMP_ID, division.Trim()); } if (!string.IsNullOrWhiteSpace(department)) { em.UpdateDepartment(idea.EMP_ID, department.Trim()); } return(Json(affectedRows)); }
public ActionResult SendMessage(string name, string email, string subject, string message) { GMailer.GmailUsername = ""; GMailer.GmailPassword = ""; GMailer mailer = new GMailer(); mailer.ToEmail = ""; mailer.Body = "Name: " + name + " Email: " + email + " Message: " + message; mailer.Subject = subject; mailer.IsHtml = true; mailer.Send(); return(View()); }
public Task SendAsync(IdentityMessage message) { //email settings GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = message.Destination; mailer.Subject = message.Subject; mailer.Body = message.Body; mailer.IsHtml = true; mailer.Send(); return(Task.FromResult(0)); }
public ActionResult ContactUs(ContactUsVM model) { if (ModelState.IsValid) { try { _unitOfWork.ContactUsRepository.Insert(new ContactUs { Name = model.Name, Email = model.EMail, Message = model.Message, CreatedDate = DateTime.Now, IsActive = true, CreatedByID = 1 }); _unitOfWork.Save(); #region sendMail1 //var toAddress = model.EMail.ToString(); //var fromAddress = "*****@*****.**"; //var subject = "Test enquiry from " + model.Name; //var message = new StringBuilder(); //message.Append("Name: " + model.Name + "\n"); //message.Append("Email: " + model.EMail + "\n"); //message.Append(model.Message); ////start email Thread //var tEmail = new Thread(() => SendMail.SendEmail(toAddress, fromAddress, subject, message.ToString())); //tEmail.Start(); #endregion #region sendMail2 GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = model.EMail.ToString(); mailer.Subject = "Verify your email id"; mailer.Body = "Thanks for Registering your account.<br> please verify your email id by clicking the link <br> <a href='youraccount.com/verifycode=12323232'>verify</a>"; mailer.IsHtml = true; mailer.Send(); TempData["NoteCss"] = "danger"; TempData["NoteText"] = "Bilinmeyen Hata!"; TempData["SuccessMail"] = "Mesajınızı Aldık! E-Postanızı Kontrol Edin."; #endregion } catch (Exception ex) { TempData["NoteCss"] = "danger"; TempData["NoteText"] = "Bilinmeyen Hata!"; TempData["NoteError"] = ex.Message; } } return(View(model)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email, Comments = new HashSet <Comment>(), TranslatedNovels = new HashSet <Novel>(), RegistrationDate = DateTime.Now, }; var addRoleResult = UserManager.AddToRole(user.Id, "User"); var result = await UserManager.CreateAsync(user, model.Password); // For more information on how to enable account confirmation and password reset please visit http://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); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Thanks for Registering your account.<br>Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = $"{user.Email}"; mailer.Subject = "Verify your email id"; mailer.Body = "Thanks for Registering your account.<br> please verify your account by clicking the link <br> <a href=\"" + callbackUrl + "\">here</a>"; mailer.IsHtml = true; mailer.Send(); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public IActionResult Mailer(ApplicationUser user) { GMailer.GmailUsername = "******"; // Set email (username) GMailer.GmailPassword = "******"; // Set password GMailer mailer = new GMailer(); // create new GMailer object mailer.ToEmail = user.Email; // Set target address string body = "Dear " + user.Name + " " + user.Surname + ",<br/><br/>Please note that Investigation updates have been made to one of your Reports! <br/><br/><br/>Regards,<br/>Nemesys"; mailer.Subject = "Nemesys: Report Update!"; //Set the subject for the email mailer.Body = body; mailer.IsHtml = true; mailer.Send(); // Send the email return(RedirectToAction("Index")); }
public ActionResult SendErrorEmail() { var error = this.GetError(); GMailer.GmailUsername = "******"; GMailer.GmailPassword = Password.EmailPassword; var mailer = new GMailer { ToEmail = "*****@*****.**", Subject = "Error Email", Body = error.StackTrace, IsHtml = true }; mailer.Send(); return(this.RedirectToAction("Index", "Home")); }
public ActionResult ContactMech(string user, string email, string message, PublicacionMec pub) { // GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer { ToEmail = pub.email, Subject = $"{user} te contactó desde Jaramillo.cl!", Body = $"{user} te contactó desde Jaramillo.cl! Devuelve el mensaje a su mail {email}, este fue su mensaje! <br> {message}", IsHtml = true }; mailer.Send(); SetSuccessMsg("Mensaje Enviado con Éxito"); return(Redirect(GetReferer(Request))); }
public ActionResult Email(string name, string email) { // Create the viewbag string ViewBag.Result = "Thanks, " + name + ". The company will send an email to " + email + "."; GMailer.GmailUsername = "******"; // THIS MUST BE AN APP SPECIFIC PASSWORD, you must set up 2 step factor authentication GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = email; mailer.Subject = "IS403 Group 1-15"; mailer.Body = "Thanks, " + name + ", for contacting us."; mailer.IsHtml = true; mailer.Send(); // Return the view return(View()); }
public ActionResult Index(string imie, string email, string telefon, string temat, string wiadomosc) { try { GMailer.GmailUsername = ConfigurationManager.AppSettings["From"]; GMailer.GmailPassword = ConfigurationManager.AppSettings["Pass"]; GMailer mailer = new GMailer(); mailer.ToEmail = email; mailer.Subject = temat; mailer.Body = string.Format("Witam <br /> Imię i nazwisko: <b>{0}</b>,<br /> Numer telefonu: <b>{1}</b>,<br />Temat: <b>{2}<b/><br /> Treść wiadomości: {3}", imie, telefon, temat, wiadomosc); mailer.IsHtml = true; mailer.Send(); } catch (Exception ex) { Response.Write("Nie można wysłać wiadomośći - wystąpił błąd: " + ex.Message); } return(View()); }
public ActionResult SendGmail() { try { GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = "*****@*****.**"; mailer.Subject = "Experiment"; mailer.Body = "Thanks for Registering your account.<br> please verify your email id by clicking the link <br> <a href='youraccount.com/verifycode=12323232'>verify</a>"; mailer.IsHtml = true; mailer.Send(); return(Content("SENT man guru")); } catch (Exception ex) { return(Content(ex.InnerException.ToString())); } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://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); //await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); // // To be abstracted away and make it async. -Yue // Try to use more decent smtp server later.-Yue // GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = user.Email; mailer.Subject = "Confirm your account"; mailer.Body = "Hi " + user.UserName + "!<br><br><br>Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a><br><br><br>From Meet.U"; mailer.IsHtml = true; mailer.Send(); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult ForgotPassword(string email) { if (!String.IsNullOrEmpty(email)) { string token = Guid.NewGuid().ToString(); var url = ResolveServerUrl(VirtualPathUtility.ToAbsolute("/Users/ResetPassword"), false) + "?token=" + token; var message = "<a href='" + url + "'>Click here to reset your password.</a>"; var user = db.Users.Where(x => x.Email == email).FirstOrDefault(); user.password_reset_token = token; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); GMailer.Send(email, "Password reset link", message); } return(View()); }
public async Task <IActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(model.Email); if (user == null || !(await _userManager.IsEmailConfirmedAsync(user))) { // Don't reveal that the user does not exist or is not confirmed return(RedirectToAction(nameof(ForgotPasswordConfirmation))); } var ctoken = await _userManager.GeneratePasswordResetTokenAsync(user); var token_link = Url.Action("ResetPassword", "Account", new { userid = user.Id, token = ctoken }, protocol: HttpContext.Request.Scheme); GMailer.GmailUsername = "******"; GMailer.GmailPassword = "******"; GMailer mailer = new GMailer(); mailer.ToEmail = user.Email; mailer.Subject = "Change your password"; mailer.Body = "Click the below link to change your password <br>" + token_link; mailer.IsHtml = true; mailer.Send(); // For more information on how to enable account confirmation and password reset please // visit https://go.microsoft.com/fwlink/?LinkID=532713 //var code = await _userManager.GeneratePasswordResetTokenAsync(user); //var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme); //await _emailSender.SendEmailAsync(model.Email, "Reset Password", // $"Please reset your password by clicking here: <a href='{callbackUrl}'>link</a>"); return(RedirectToAction(nameof(ForgotPasswordConfirmation))); } // If we got this far, something failed, redisplay form return(View(model)); }
public void SendEmail(string emailAddress, string Name, string Reason, string Message) { GMailer.GmailUsername = "******"; GMailer.GmailPassword = ""; if (Reason == "SignUp") { Reason = "Sign Up"; } else { Reason = "Learn More"; } GMailer mailer = new GMailer { ToEmail = "*****@*****.**", Subject = Reason, Body = "The following message is from the Lend My Auto website: " + Environment.NewLine + Name + " wants to " + Reason + ". They left the following message: " + Message + Environment.NewLine + " Their email address is: " + emailAddress, IsHtml = true }; mailer.Send(); }