Send email for Password Recovery Program, Password from Database, C# asp.net 2.0, SQL-server
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="forpasswd.aspx.cs" Inherits="forpasswd" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Password Recover</title>
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="21 days" />
<meta name="author" content="" />
<meta name="copyright" content="" />
<meta name="rating" content="Global" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="Description" content="" />
<meta name="Keywords" content="" />
<meta name="abstract" content="" />
<link type="text/css" rel="stylesheet" href="css/layout.css" title="default" media="all" />
</head>
<body id="home">
<form id="form1" runat="server">
<div id="main-wrapper">
<div id="header">
<a href="default.aspx">xxxxxxxx</a></div>
<div id="navigation"><center>
<asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="White" Text="Recover Your Password "></asp:Label>
</center>
</div>
<div id="content-wrapper"> <br />
<table style="width:100%" bgcolor="White"><tr>
<td style="height: 17px; width: 503px;">
<div style="text-align: center">
<table style="width: 70%" align="center">
<tr>
<td align="center" colspan="2">
</td>
</tr>
<tr>
<td align="right" colspan="">
<asp:Label ID="Label2" runat="server" Text="Your Email ID:"></asp:Label></td>
<td align="left">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" /></td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="txtmesge" runat="server" Width="331px"></asp:Label></td>
</tr>
<tr>
<td style="height: 17px">
</td>
<td style="height: 17px">
</td>
</tr>
</table>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</td>
</tr>
</table>
<br />
<br />
<div class="clear"></div>
</div>
<div id="feature-box">
<br />
<div class="clear"></div>
</div><center><font size="1px" color="gray">
© 2009 ABC,LLC</font></center></div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
public partial class forpasswd : System.Web.UI.Page
{
string struser;
string strpasswd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "" || TextBox1.Text == null)
{
txtmesge.Text = "Invalid Blanks.";
}
else
{
getpassdata();
}
}
void getpassdata()
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
string strSQL = "select * FROM UserDetails WHERE UDEMAIL='" + TextBox1.Text + "'";
string STRpass = "";
SqlCommand cmd = new SqlCommand(strSQL, myConnection);
myConnection.Open();
SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (myReader.Read())
{
strpasswd = myReader["UDPASSWD"].ToString();
struser = myReader["UDUSRID"].ToString();
// Response.Write(strSQL);
// Response.End();
if (strpasswd.Trim() == null)
{
txtmesge.Text = "No Matches Found.";
}
else
{
sendemailpasswd();
}
break;
}
if (strpasswd == null)
{
txtmesge.Text = "No Matches Found, Please contact Admin.";
}
myReader.Close();
myConnection.Close();
}
void sendemailpasswd()
{
MailMessage objEmail = new MailMessage();
objEmail.To = TextBox1.Text.Trim();
objEmail.From = "YourEmail@abc.net";
objEmail.Subject = "User Credentials For Gross Profit Reports";
String EmailBody = "";
EmailBody = "<html>";
EmailBody += "<Body>";
EmailBody += "<table border=0 width=30% align=center bgcolor=#f1fff9 cellpadding=5 >";
EmailBody += "<tr><td colspan=2 align=center bgcolor=#dff6d2 ><b>Your User Credentials:</b></td></tr>";
EmailBody += "<tr><td >User:</td>";
EmailBody += "<td align=left>" + struser + "</td></tr>";
EmailBody += "<tr><td>Password:</td>";
EmailBody += "<td align=left>" + strpasswd + "</td></tr>";
EmailBody += "</table>";
EmailBody += "</Body>";
EmailBody += "</Html>";
objEmail.Body = EmailBody;
objEmail.Priority = MailPriority.High;
objEmail.BodyFormat = MailFormat.Html;
// Make sure you have appropriate replying permissions from your local system
SmtpMail.SmtpServer = "mail.YOURDOMAIN.net";
try
{
SmtpMail.Send(objEmail);
txtmesge.Text = "User Credentials Sent.Check Your Email.";
TextBox1.Text = "";
}
catch (Exception exc)
{
Response.Write("Send failure: " + exc.ToString());
}
}
private string ConnectionString
{
get
{
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString;
return connectionString;
}
}
}
4 comments:
For execute this action to my mind ther is next utiltiy-recover deleted outlook express messages,it is one of the best in this sphere,program has free status as far as I remember,it can process dbx files regardless of the cause of their damage,supports even batch mode recovering,compatible with Windows NT 4.0, Windows Me, Windows 98, Windows 2000, Windows 2003, Windows XP, Windows Vista and all versions of Outlook Express, currently supported by Microsoft Corporation,recover deleted Outlook Express email, because it is very important to start working with this program and recover deleted messages Outlook Express to prevent further corruption of dbx files,program can restore the data, that was destroyed by viruses, hardware errors and other faults.
Some days ago I synchronised my contacts on computer with mobile,and unexpectedly all my contacts on PC was deleted.But accidentally in inet I found-outlook express extract dbx.Software has free status as far as I remember,it recover my contacts.In addition program can likewise epair messages from all folders and extract .dbx files.
Couple days ago I worked with nice tool-outlook password recovery software,it helped to recover all my old mails.Moreover program made it in a minute.This tool for me advised my friend.Program showed recover lost or forgotten passwords for the mail accounts and *.pst files of the Microsoft Outlook mail client.
This type of problems can be solved with pst repair tools, it gives perfect results.
Post a Comment