how to send forget password send on mail
Regards
Selastin
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Akhil MittalPosted May 16, 2014, 5:23 AM
Akhil MittalPosted May 16, 2014, 5:22 AM
From http://srmscrm.wordpress.com/2012/11/14/asp-net-with-c-sending-email-send-password-to-the-email/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BAL;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Net.Mail;
using System.Web.Mail;
using System.Net;
public partial class ForgotPassword : System.Web.UI.Page
{
string forgotPwd;
string email;
string pwd = "myswamimyguru";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSendSms_Click(object sender, EventArgs e)
{
BusinessAccessLayer BAL = new BusinessAccessLayer();
DataSet datasetValues = null;
string userid = txtRetUserId.Text;
try {
//datasetValues = BAL.RetrieveforgotPwdBAL(userid);
//forgotPwd = datasetValues.Tables[0].Rows[0]["Ppassword"].ToString();
//email = datasetValues.Tables[0].Rows[0]["EmailId"].ToString();
txtFrom.Text = "srivivekcollegeofengineering@gmail.com";
txtTo.Text = email;
txtSubject.Text = "Forgot Password";
txtMailBody.Text = "Your Password is" + forgotPwd + " Please Login with the credentials";
}
catch (Exception ex)
{
throw;
}
finally
{
BAL = null;
}
}
protected void btnGetDetails_Click(object sender, EventArgs e)
{
System.Net.Mail.MailMessage mailMessege = newSystem.Net.Mail.MailMessage(txtFrom.Text, txtTo.Text,txtSubject.Text, txtMailBody.Text);
SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com", 587);
mailMessege.IsBodyHtml = false;
NetworkCredential nCred = new NetworkCredential(txtFrom.Text, pwd);
SMTPServer.DeliveryMethod = SmtpDeliveryMethod.Network;
SMTPServer.UseDefaultCredentials = false;
SMTPServer.Credentials = nCred;
SMTPServer.EnableSsl = true;
SMTPServer.Timeout = 20000000;
try
{
SMTPServer.Send(mailMessege);
}
catch (Exception ex) {
Label1.Text = ex.ToString();
}
}
}
In the web.config add the following code