http://stackoverflow.com/questions/9104645/cant-auth-to-gmail-smtp-via-mailmessage-smtpclient
private string GeneratePassword()
{
string strPwdchar = "abcdefghijklmnopqrstuvwxyz0123456789#+@&$ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string strPwd = "";
for (int i = 0; i <= 7; i++)
{
int iRandom = Objrnd.Next(0, strPwdchar.Length - 1);
strPwd += strPwdchar.Substring(iRandom, 1);
}
return strPwd;
}
protected void SendMail()
{
SmtpClient smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
UseDefaultCredentials = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential("manabadi@gmail.com", "$Mana$Results$Portal15$"),
EnableSsl = true,
Timeout = 10000
};
MailMessage message = new MailMessage();
message.Body = GeneratePassword();
message.Subject = "Your Password Details";
message.To.Add(txtemail.Value);
message.From = new MailAddress(txtemail.Value);
smtp.Send(message);
}
private string GeneratePassword()
{
string strPwdchar = "abcdefghijklmnopqrstuvwxyz0123456789#+@&$ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string strPwd = "";
for (int i = 0; i <= 7; i++)
{
int iRandom = Objrnd.Next(0, strPwdchar.Length - 1);
strPwd += strPwdchar.Substring(iRandom, 1);
}
return strPwd;
}
protected void SendMail()
{
SmtpClient smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
UseDefaultCredentials = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential("manabadi@gmail.com", "$Mana$Results$Portal15$"),
EnableSsl = true,
Timeout = 10000
};
MailMessage message = new MailMessage();
message.Body = GeneratePassword();
message.Subject = "Your Password Details";
message.To.Add(txtemail.Value);
message.From = new MailAddress(txtemail.Value);
smtp.Send(message);
}
No comments:
Post a Comment
Hello all, if you have any doubt feel free comment