Muhammad Tayyab

Muhammad Tayyab

  • NA
  • 96
  • 553

How to pass the random number into mail in MVC 5

Jan 24 2018 4:18 AM
public ActionResult forgetPass(ChangePasswordModel obj)
{
DemoContext _context = new DemoContext();
User objUser = _context.Users.SingleOrDefault(x => x.EmailID.Equals(obj.CurrentEmail));
if(objUser!=null)
{
Random R = new Random();
int Rend = R.Next(100, 1000);
TempData["GenerateNo"] = Rend;
TempData.Keep();
//ViewBag.Gen = Rend;
//BuildEmailTemplate1(objUser.ID);
try
{
SmtpClient clt = new SmtpClient("smtp.myserver.com", 564);
clt.EnableSsl = true;
clt.Credentials = new NetworkCredential("[email protected]", "@@@123456789T");
clt.Send("[email protected]", objUser.EmailID, "WelCome to the OLX (Online Buying and selling)", "this is the Verification Code that we have send to you for the ");
}
catch(SmtpException ex)
{
// //error me
}
return RedirectToAction("UserProfile");
}
return View();
}