public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { string confirmationToken = WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.Email }, true); Roles.AddUserToRole(model.UserName, "User"); dynamic email = new Postal.Email("RegEmail"); email.To = model.Email; email.UserName = model.UserName; email.ConfirmationToken = confirmationToken; email.Send(); return(RedirectToAction("RegisterStepTwo", "Account")); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return(View(model)); }
public void SendInquiry(EmailModel _email, string TemplateName) { dynamic email = new Postal.Email(TemplateName); email.To = _email.EmailTo; email.From = "*****@*****.**";// _email.From; if (_email.EmailCC != null) { email.Cc = _email.EmailCC; } if (_email.EmailBCC != null) { email.Bcc = _email.EmailBCC; } email.FullName = _email.FullName; email.ContactNo = _email.ContactNo; email.Message = _email.Message; email.TourName = _email.TourName; email.Email = _email.ClientEmail; email.Send(); }
/// <summary> /// CareManager verifies here. /// </summary> /// <param name="verificationCode"></param> /// <returns></returns> public async Task <ActionResult> Verify(string verificationCode) { var row = db.EmailVerifications.FirstOrDefault(v => v.VerificationCode == verificationCode); if (row == null) { Flash("無効なURLです。"); return(RedirectToAction("Index", "Home")); } if (row.CareManager.User != null) { Flash("そのケアマネは既に認証されています。"); return(RedirectToAction("Index", "Home")); } // Generates username and password. var username = string.Format("CM{0:D6}", row.CareManagerId); var password = Helper.PasswordHelper.GeneratePassword(12); // Registers CareHomeUser. var user = new User() { UserName = username, Email = row.Email, Name = row.CareManager.Name }; var result = await UserManager.CreateAsync(user, password); if (!result.Succeeded) { throw new Exception("会員を登録できませんでした。"); } var registeredUser = db.Users.FirstOrDefault(u => u.UserName == username); if (registeredUser == null) { throw new Exception("登録されたはずの会員が見つかりませんでした。"); } // Notifies Sender. Flash("ケアマネ会員として認証されました。IDとパスワードを電子メールアドレスにお送りいたしましたのでご確認ください。"); //SendEmail(registeredUser.Email, "[ケアマネ情報局] ケアマネ会員として認証されました", string.Format("ID:{0} password:{1}", username, password)); dynamic email = new Postal.Email("EmailVerified"); email.To = registeredUser.Email; email.CareHomeName = row.CareManager.CareHome.Name; email.CareManagerName = row.CareManager.Name; email.UserId = username; email.Password = password; email.SiteUrl = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority); email.Send(); // Adds CareManager and deletes EmailVerification. registeredUser.CareManager.Add(row.CareManager); db.EmailVerifications.Remove(row); db.SaveChanges(); Log(LogType.CareManager, "ケアマネ会員としてメール認証しました。", new { row.Email, row.CareManagerId }); return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> ApproveConfirmed(int id, string noteForSender) { var application = db.Applications.Find(id); if (application == null) { return(HttpNotFound()); } if (application.CareHome.User != null) { throw new InvalidOperationException("該当する事業所会員は既に登録されています。"); } // Generates username and password. var username = "******" + application.CareHome.CareHomeCode; var password = Helper.PasswordHelper.GeneratePassword(12); // Registers CareHomeUser. var user = new User() { UserName = username, Email = application.Email, Name = application.Name }; var result = await UserManager.CreateAsync(user, password); if (!result.Succeeded) { throw new Exception("会員を登録できませんでした。"); } var registeredUser = db.Users.FirstOrDefault(u => u.UserName == username); if (registeredUser == null) { throw new Exception("登録されたはずの会員が見つかりませんでした。"); } // Notifies Sender. //SendEmail(registeredUser.Email, "[ケアマネ情報局] 事業所会員として承認されました", string.Format("ID:{0} password:{1} 備考:{2}", username, password, noteForSender)); dynamic email = new Postal.Email("ApplicationApproved"); email.To = registeredUser.Email; email.CareHomeName = application.CareHome.Name; email.CareHomeUserName = application.Name; email.UserId = username; email.Password = password; email.SiteUrl = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority); email.Note = noteForSender; email.Send(); // Adds CareHome and deletes Application. registeredUser.CareHomes.Add(application.CareHome); db.Applications.Remove(application); db.SaveChanges(); Flash(string.Format("承認されました。ID:{0}", username)); Log(LogType.Admin, "事業所会員登録申請を承認しました。"); return(RedirectToAction("Index")); }
public ActionResult SendTestEmail() { dynamic email = new Postal.Email("Test"); email.To = "*****@*****.**"; email.Message = "How do you feel to day. Sent at " + DateTime.Now.ToString(); email.Send(); return(RedirectToAction("Index")); }
public ActionResult EmailTest() { //SendEmailToAdmin("Hi", "Hello"); dynamic email = new Postal.Email("Example"); email.To = "*****@*****.**"; email.FunnyLink = "http://example.com/"; email.Send(); return(null); }
public void SendError(EmailModel _email, string TemplateName) { dynamic email = new Postal.Email(TemplateName); email.To = _email.EmailTo; email.From = "*****@*****.**";// _email.From; if (_email.EmailCC != null) { email.Cc = _email.EmailCC; } if (_email.EmailBCC != null) { email.Bcc = _email.EmailBCC; } email.ErrorMessage = _email.ErrorMessage; email.Send(); }
/// <summary> /// Send email in new thread /// </summary> /// <param name="to">to</param> /// <param name="username">username</param> /// <param name="subject">subject</param> /// <param name="body">body</param> /// <param name="confirmationToken">confirmationToken</param> /// <param name="template">template</param> /// <param name="hostUrl">hostUrl</param> private static void SendEmailInBackground(string to, string username, string subject, string body, string confirmationToken, EmailTemplate template, string hostUrl) { try { dynamic email = new Postal.Email(template.ToString()); email.To = to; email.From = new System.Net.Mail.MailAddress("*****@*****.**", "צוות תמיכה של TeachMe"); if (!string.IsNullOrEmpty(subject)) { email.Subject = subject; } if (!string.IsNullOrEmpty(body)) { email.Body = body; } email.UserName = username; email.ConfirmationToken = confirmationToken; email.HostUrl = hostUrl; email.Send(); } catch (System.Exception) { } }
public void SendEmail(EmailModel _email, string TemplateName) { dynamic email = new Postal.Email(TemplateName); email.To = _email.ClientEmail; email.From = _email.From; if (_email.EmailBCC != null) { email.Cc = _email.EmailCC; } if (_email.EmailCC != null) { email.Bcc = _email.EmailBCC; } email.HotelName = _email.HotelName; email.RoomCategory = _email.RoomCategory; email.CheckIn = _email.CheckIn; email.CheckOut = _email.CheckOut; if (_email.PackageType != null) { email.Package = _email.PackageType; } email.InvoiceNo = _email.BookingRef; email.InvoiceAmount = _email.InvoiceAmount; email.BookingRef = _email.BookingRef; email.Amount = _email.Amount; email.ClientEmail = _email.ClientEmail; email.ClientName = _email.ClientName; email.DateofPayment = _email.DateofPayment.ToShortDateString(); email.Send(); }
public ActionResult Edit(string code, [Bind(Include = "CareManagerId,CareHomeId,Email,MediaFileDataId,Name,Gender,Age,Licensed,Licenses,CurrentPatients,AllowNewPatient,Career,Messages,BlogUrls,TotalRating,ReviewsCount,Rating,Birthday")] CareManager caremanager, HttpPostedFileBase file, int year, int month, int day) { // Checks file size. if (file != null && file.ContentLength > 200000) { ModelState.AddModelError("", "アップロードできる画像のサイズは200kBまでです。"); } // Sets Dec. 31th. caremanager.Birthday = new DateTime(year, month, day); caremanager.Licensed = new DateTime(caremanager.Licensed.Year, 12, 31); if (ModelState.IsValid) { // Uploads Image if (file != null) { BlobHelper.DeleteIfExists("mediafile", caremanager.MediaFileDataId); caremanager.MediaFileDataId = BlobHelper.Upload("mediafile", file, file.FileName); } // Adds / Edits record if (caremanager.CareManagerId == 0) { // Add db.CareManagers.Add(caremanager); var verification = new EmailVerification() { CareManager = caremanager, Email = caremanager.Email }; db.EmailVerifications.Add(verification); db.SaveChanges(); // Notifies CareManager to verify. //SendEmail(caremanager.Email, "[ケアマネ情報局] ケアマネ会員認証", "URL: " + Url.Action("Verify", "EmailVerification", new { verificationCode = verification.VerificationCode}, Request.Url.Scheme)); var added = db.CareManagers.Include(m => m.CareHome).FirstOrDefault(m => m.CareManagerId == caremanager.CareManagerId); dynamic email = new Postal.Email("CareManagerAdded"); email.To = added.Email; email.CareManagerName = added.Name; email.CareHomeName = added.CareHome.Name; email.CareHomeUserName = ""; if (added.CareHome.User != null) { email.CareHomeUserName = added.CareHome.User.Name; } email.VerificationUrl = Url.Action("Verify", "EmailVerification", new { verificationCode = verification.VerificationCode }, Request.Url.Scheme); email.SiteUrl = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority); email.Send(); } else { // Edit var entry = db.Entry(caremanager); entry.State = EntityState.Unchanged; entry.Property(p => p.Email).IsModified = true; entry.Property(p => p.Name).IsModified = true; entry.Property(p => p.Gender).IsModified = true; entry.Property(p => p.Licensed).IsModified = true; entry.Property(p => p.Birthday).IsModified = true; if (file != null) { entry.Property(p => p.MediaFileDataId).IsModified = true; } db.SaveChanges(); } Log(LogType.CareHome, "所属するケアマネの情報を更新しました。"); return(RedirectToAction("Index")); } ViewBag.Gender = EnumHelper <Gender> .GetSelectList(caremanager.Gender); ViewBag.Year = Helper.Helper.GetBirthdayYears(caremanager.Birthday); ViewBag.Month = Helper.Helper.GetBirthdayMonths(caremanager.Birthday); ViewBag.Day = Helper.Helper.GetBirthdayDays(caremanager.Birthday); ViewBag.Licensed = Helper.Helper.GetLicensedYears(caremanager.Licensed); return(View(caremanager)); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { string confirmationToken = WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.Email }, true); Roles.AddUserToRole(model.UserName, "User"); dynamic email = new Postal.Email("RegEmail"); email.To = model.Email; email.UserName = model.UserName; email.ConfirmationToken = confirmationToken; email.Send(); return RedirectToAction("RegisterStepTwo", "Account"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return View(model); }