This is my Otp generation code I need to save msg.body into data base pls help me out..
string newPwd = GenerateOtp().ToString();
Session["session1"] = newPwd;
MailMessage msg = new MailMessage();
msg.From = new MailAddress("[email protected]");
msg.To.Add(TextBox1.Text);
string name = newtxtbx.Text;
msg.Subject = "Pls Verify Below Otp";
msg.Body = "Hi Dear!" + "\n" + name + "\n" + " Your Otp is " + "\n " + newPwd + " " + "Generated and Sent By" + "\n" + "K.J.S.P";
msg.IsBodyHtml = true;
SmtpClient smt = new SmtpClient();
smt.Host = "smtp.gmail.com";
System.Net.NetworkCredential ntwd = new NetworkCredential();
ntwd.UserName = "[email protected]";
ntwd.Password = "tmfegdxjspdadyyt";
smt.UseDefaultCredentials = true;
smt.Credentials = ntwd;
smt.Port = 587;
smt.EnableSsl = true;
smt.Send(msg);
//lblMessage.Text = "Email Sent Successfully";
Response.Write("");
Session["msg"] = msg;
//lblMessage.ForeColor = System.Drawing.Color.ForestGreen;
Button2.Text = "Email";
This my code to save into database once i received otp to my mail i am able to save otp but when i want to save message into db showing "SqlServer system.net.mailmessage " this error pls help me out with this
ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "confirm('Your Email Has Been Verified Successfully.');", true);
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
SqlCommand cmd = new SqlCommand("sp_SaveOtpDetails", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@username", newtxtbx.Text);
cmd.Parameters.AddWithValue("@email", TextBox1.Text);
cmd.Parameters.AddWithValue("@otps", Session["session1"]);
cmd.Parameters.AddWithValue("@msg", Session["msg"]);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
Naimish MakwanaPosted Feb 23, 2023, 8:55 AM
Hello Jaya,
Try to change
To
Thanks
Naimish Makwana
Jaya PrakashPosted Feb 23, 2023, 9:03 AM
Thank You so much sir working fine. I need more guidence from u sir...
Jaya PrakashPosted Feb 23, 2023, 8:50 AM
hit sir i have to save
this msg in database ..
msg.Body = "Hi Dear!" + "\n" + name + "\n" + " Your Otp is " + "\n " + newPwd + " " + "Generated and Sent By" + "\n" + "K.J.S.P";
Naimish MakwanaPosted Feb 23, 2023, 8:48 AM
Hello Jaya,
What you want to do with above code?
Thanks
Naimish Makwana