how to send username and password to email in asp.net

Advertisement
In this article I will explain how to send User id and password,when your are inserting the data first tie it will generate Password,it will sent mail to that Email id.

Add Name Space: using System.Net.Mail;

 public void sendingUidPwd(String Uid, String pwd)
        {
            try
            {
                MailMessage objeto_mail = new MailMessage();
                SmtpClient client = new SmtpClient();
                client.Port = 25;
                client.Host = "smtp.gmail.com";
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials = new System.Net.NetworkCredential("yourmailid@gmail.com", "12345687");
                client.EnableSsl = true;
                objeto_mail.From = new MailAddress("yourmailid@gmail.com");
                objeto_mail.To.Add(new MailAddress(Uid));
                objeto_mail.Subject = "Your User ID and Password ";
                //objeto_mail.CC.Add(new MailAddress("phaniraavi@gmail.com"));
                objeto_mail.Body = "\n\nYour User ID and Password From RaaviChinnu.\n\n UserID : " + Uid + "\n\n Password : " + pwd;
                client.Send(objeto_mail);
            }
            catch (Exception)
            {
                
                
            }
        }



Call this method in Insert Method.

sendingUidPwd(txtEmailID.Text, pwd);

It will work :)
Advertisements
SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a comment