protected void send_mail()
{
String genpass;
genpass = GeneratePassword();
lblResult.Text = genpass.ToString();
string mail_id = "xtream.hell97@gmail.com";
string mail_password = "XXXXXXX";
MailMessage msg = new MailMessage();
msg.From = new MailAddress(mail_id, "Apiit Library");
msg.To.Add(new MailAddress(txt_email.Text));
msg.Subject = "Password Information Of LMS";
msg.Body = "Your password is" + ": " + genpass;
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new NetworkCredential(mail_id, mail_password);
smtp.EnableSsl = true;
try
{
smtp.Send(msg);
create_user_query(genpass);
lblResult.Text = "Email send successfully:";
}
catch (Exception ex)
{
lblResult.Text = ex.Message;
}
}
private string GeneratePassword()
{
string strPwdchar = "abcdefghijklmnopqrstuvwxyz0123456789#+@&$ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string strPwd = "";
Random rnd = new Random();
for (int i = 0; i <= 7; i++)
{
int iRandom = rnd.Next(0, strPwdchar.Length - 1);
strPwd += strPwdchar.Substring(iRandom, 1);
}
return strPwd;
}
i want to send this email in formated html with logo. So i want to chane only its body part with html page to send users auto generated password.