In Web Config
<system.net>
<mailSettings>
<smtp from="XXXXX@gmail.com">
<network host="smtp.gmail.com" port="587" userName="XXXX@gmail.com" password="XXX" defaultCredentials="false" />
</smtp>
</mailSettings>
</system.net>
In C#
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
System.Net.Mail.MailMessage smail = new System.Net.Mail.MailMessage();
smail.Subject = "Subject of the Mail";
smail.Body = "Body of the Mail";
smail.To.Add("YYYYYY@gmail.com"); // or smail.To.Add(Textbox.Text);
smail.From = new System.Net.Mail.MailAddress("XXXX@gmail.com");
smail.IsBodyHtml = true;
smtp.EnableSsl = true;
smtp.Send(smail);
<system.net>
<mailSettings>
<smtp from="XXXXX@gmail.com">
<network host="smtp.gmail.com" port="587" userName="XXXX@gmail.com" password="XXX" defaultCredentials="false" />
</smtp>
</mailSettings>
</system.net>
In C#
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
System.Net.Mail.MailMessage smail = new System.Net.Mail.MailMessage();
smail.Subject = "Subject of the Mail";
smail.Body = "Body of the Mail";
smail.To.Add("YYYYYY@gmail.com"); // or smail.To.Add(Textbox.Text);
smail.From = new System.Net.Mail.MailAddress("XXXX@gmail.com");
smail.IsBodyHtml = true;
smtp.EnableSsl = true;
smtp.Send(smail);
No comments:
Post a Comment