Code for sending mail in website easy smtp mail transfer code just replace username and password with
your credentials and add it your website
public bool sndmail(string
s9 ,string password )
{
string s9 = your
to address where to send
try
{
MailMessage
msg1 = new MailMessage();
msg1.From = new MailAddress("your user name");
msg1.To.Add(new MailAddress(s9.Trim()));
msg1.Subject = " Password";
msg1.Body = "This is your Password:" + password;
msg1.IsBodyHtml = true;
SmtpClient
sc = new SmtpClient("smtp.gmail.com", 587);
System.Net.NetworkCredential
basicAuthentication = new System.Net.NetworkCredential("youremail
user name" your password");
sc.EnableSsl = true;
sc.UseDefaultCredentials = false;
sc.DeliveryMethod = SmtpDeliveryMethod.Network;
sc.Credentials =
basicAuthentication;
sc.Send(msg1);
return
flag;
}
catch (Exception e)
{
flag = false;
return
flag;
}
}
Comments
Post a Comment
Thank you for your Comment