PDA

View Full Version : Giúp em viết code cho recaptcha với!



khongyeu09
01-01-2011, 07:40
em làm một trang sent mail! muốn có recaptcha để chống spam! em đã nhúng recaptcha vào webfom rùi! nhưng mà viết code để nhập dữ liệu đúng mới chạy! còn nhập sai thì báo lỗi! lại không chạy nó báo lỗi hoài! hic hic! web em asp.net các anh chị giúp em với! thanks ạ!
đoạn code trong file .cs sent mail của em đây ạ!

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;

public partial class lienhe : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnSend_Click(object sender, EventArgs e)

{
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new System.Net.NetworkCredential("abcdef@gmail.com", "******");
SmtpServer.Port = 587;
SmtpServer.Host = "smtp.gmail.com";
SmtpServer.EnableSsl = true;
MailMessage mail = new MailMessage();
String[] addr = txtTo.Text.Split(',');
try
{
mail.From = new MailAddress("abcdef@gmail.com", "Liên Hệ", System.Text.Encoding.UTF8);
Byte i;
for (i = 0; i < addr.Length; i++)
mail.To.Add(addr[i]);
mail.Subject = txtSubject.Text;
mail.Body = txtConTent.Text;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mail.ReplyTo = new MailAddress(txtTo.Text);
SmtpServer.Send(mail);

}
catch (Exception ex) { }
}
}

em cảm ơn nhiều nhiều ạ!

[=========> Bổ sung bài viết <=========]

Hic hem ai giúp em à :(