<pre> [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { UserName = model.UserName }; user.Email = model.Email; user.ConfirmedEmail = false; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage( new System.Net.Mail.MailAddress("ggcobani@gmail.com", "Web Registration"), new System.Net.Mail.MailAddress(user.Email)); m.Subject = "Email confirmation"; m.Body = string.Format("Dear {0}<BR/>Thank you for your registration, please click on the below link to complete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>", user.UserName, Url.Action("ConfirmEmail", "Account", new { Token = user.Id, Email = user.Email }, Request.Url.Scheme)); m.IsBodyHtml = true; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.mydomain.com"); smtp.Credentials = new System.Net.NetworkCredential("ggcobani@gmail.com", "password"); smtp.EnableSsl = true; smtp.Send(m); return RedirectToAction("Confirm", "Account", new { Email = user.Email }); } else { AddErrors(result); } } // If we got this far, something failed, redisplay form return View(model); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)