Category WEB CONFIG

Send Mail in Forget Password Using Config File in Asp.net

Category: ASP.NETMAIL WORKSWEB CONFIG Comments: One comment

Creating SMTP in Web Config File

<configuration>
<connectionStrings>
<add name=”Connection” connectionString=”Data Source=.\SQLExpress;Initial Catalog=practise;Integrated Security=True;” providerName=”System.Data.SqlClient”/>
</connectionStrings>
<system.net>
<mailSettings >
<smtp>
<network host=”smtp.gmail.com” port=”587″ userName=”Email Id” password=”Password” />
</smtp>
</mailSettings>
</system.net>
<appSettings>
<add key=”MailFrom” value=”Email Id”/>
</appSettings>
</configuration>
//Call this Function From where u want to sen Email using App Settings in Config File

public bool ForgetEmail(string UserName)
{
string Connection = ConfigurationManager.ConnectionStrings["Connection"].ToString();
SqlConnection con = new SqlConnection(Connection);
con.Open();

SqlCommand command = new SqlCommand(“SELECT Password from UserTable where email=’” + UserName + “‘ “, con);
SqlDataAdapter da = new SqlDataAdapter(command);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables["Table"].Rows.Count > 0)
{

SmtpClient sm = new SmtpClient();
MailMessage msg = new MailMessage();

string msgfromadd = ConfigurationManager.AppSettings["MailFrom"];
MailAddress frmadd = new MailAddress(msgfromadd);
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.From = frmadd;
msg.To.Add(EmailID);
msg.Subject = “Your Password.”;
msg.Body = “Your password is:”+” “+ds.Tables["Table"].Rows[0][0].ToString();
msg.IsBodyHtml = true;
con.Close();
sm.EnableSsl = true;

sm.Send(msg);
return true;
con.Close();
}
else
{
return false;
con.Close();
}
}

Read More

Send Mail Using Config File in Asp.net

Category: ASP.NETMAIL WORKSWEB CONFIG Comments: No comments

Creating SMTP in Web Config File

<configuration>
<system.net>
<mailSettings >
<smtp>
<network host=”smtp.gmail.com” port=”587″ userName=”Email Id” password=”Password” />
</smtp>
</mailSettings>
</system.net>
<appSettings>
<add key=”MailFrom” value=”Email Id”/>
</appSettings>
</configuration>
//Call this Function From where u want to sen Email using App Settings in Config File

public bool SendEmail(string name, string email, string sub,string msg1,string phone )
{
SmtpClient sm = new SmtpClient();
MailMessage msg = new MailMessage();

string msgfromadd = ConfigurationManager.AppSettings["MailFrom"];
MailAddress frmadd = new MailAddress(msgfromadd);
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.From = frmadd;
msg.To.Add(email);
msg.Subject = name + ” ” + sub + ” ” + phone;
msg.Body = msg1;
msg.IsBodyHtml = true;

sm.EnableSsl = true;
try
{
sm.Send(msg);
return true;
}
catch
{
return false;
}
}

Read More

Connection strings in web.config file using asp.net

Category: ASP.NETWEB CONFIG Comments: No comments

Connection strings in web.config file using asp.net 1. Connection string for userid and password 2. Connection string for integrated security Read More