/*On design view Drop the Four Text Box And Button for sending Mail
1)From(For Name)
2)To (Recepient Email Address)
3)Subject
4)Body*/
protected void btnMail_Click(object sender, EventArgs e)
{
SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);
mailClient.EnableSsl = true;
//In Network Credential give ur UserName and Password
NetworkCredential cred = new NetworkCredential("sheeban101pk@gmail.com", "xxxxxx");
mailClient.Credentials = cred;
try
{
mailClient.Send(tbxFrom.Text.Trim(), tbxTo.Text.Trim(), tbxSubject.Text.Trim(), tbxBody.Text.Trim());
Response.Write("Your Email has been sent sucessfully -Thank You");
}
catch (Exception exc)
{
Response.Write("Send failure: " + exc.ToString());
}
}
No comments:
Post a Comment