i am done email sending after submit the form.but i can`t send otp to email.
- [AllowAnonymous]
- [Route("Register")]
- public async Task
Register(RegisterBindingModel model) - {
- if (!ModelState.IsValid)
- {
- return BadRequest(ModelState);
- }
- var user = new ApplicationUser() { UserName = model.Email, Email = model.Email };
- IdentityResult result = await UserManager.CreateAsync(user, model.Password);
- if (!result.Succeeded)
- {
- return GetErrorResult(result);
- }
- MailMessage mm = new MailMessage("fromemail", "toemail");
- mm.Subject ="Leave Reject";
- mm.Body = "Hi Sir, " ;
- mm.IsBodyHtml = false;
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.Port = 587;
- smtp.UseDefaultCredentials = false;
- smtp.Credentials = new System.Net.NetworkCredential("email", "password");
- smtp.EnableSsl = true;
- smtp.Send(mm);
- return Ok();
- }
Sachin SinghPosted May 18, 2021, 2:31 PM
Your password is {1}{2}.
Thank You.", username, password, strNewPassword);
selvi jpPosted May 19, 2021, 4:24 AM