protected void Button1_Click(object sender, EventArgs e)
{
try
{
MailMessage message = new MailMessage();
SmtpClient mailClient = new SmtpClient();
MailAddress frm = new MailAddress(txtmailfrom.Text);
message.To.Add(txtmailto.Text);
message.Subject = txtsubject.Text;
String bodyText = "";
bodyText = " ";
bodyText = bodyText + "Dear" + " " + "firstname" + " " + "lastname" + ",";
bodyText = bodyText + "
";
bodyText = bodyText + "
";
bodyText = bodyText + "Administrator has sent reply on your Registration:";
bodyText = bodyText + " " + "" + txtsubject.Text + "";
bodyText = bodyText + "
";
bodyText = bodyText + "RegistrationDate:";
bodyText = bodyText + " " + "" + DateTime.Now.ToString() + "";
bodyText = bodyText + "
";
bodyText = bodyText + "If you have any queries or want to send nominations, please mail the same to
href='mailto:YOURADMNEMAILID'>YOURADMNEMAILID " + "
";
bodyText = bodyText + "
";
bodyText = bodyText + "All the best!!";
bodyText = bodyText + "
";
bodyText = bodyText + "
";
bodyText = bodyText + "Regards,";
bodyText = bodyText + "
";
bodyText = bodyText + "WEBSITE";
bodyText = bodyText + "";
message.Body = bodyText.ToString();
message.IsBodyHtml = true;
message.Priority = MailPriority.High;
NetworkCredential basicAuthenticationInfo = new NetworkCredential(@"YOURGMAILID", "G-MAIL PWD");
mailClient.Host = "smtp.gmail.com";
mailClient.Port = 587;
mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mailClient.UseDefaultCredentials = false;
mailClient.EnableSsl = true;
mailClient.Credentials = basicAuthenticationInfo;
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
//mailClient.Timeout = 60000;
mailClient.Send(message);
lbl_success.Text = "Successsssss";
}
catch(Exception ex)
{
lbl_success.Text = "faillllll.";
}
}
Saturday, February 20, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment