DOWNLOAD
using System.Net;
using System.Net.Mail;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
MailMessage msgobj;
SmtpClient serverobj = new SmtpClient();
serverobj.Credentials = new NetworkCredential(TextBox1.Text, TextBox2.Text);
serverobj.Port = 587;
serverobj.Host = "smtp.gmail.com";
serverobj.EnableSsl = true;
msgobj = new MailMessage();
msgobj.From = new MailAddress(TextBox1.Text, "hi", System.Text.Encoding.UTF8);
msgobj.To.Add(TextBox3.Text);
msgobj.Subject = TextBox4.Text;
msgobj.Body = TextBox5.Text;
// msgobj .Attachments .Add (new Attachment (MapPath ("pocketpc.gif"));
msgobj.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
serverobj.Send(msgobj);
Label5.Visible = true;
Label5.Text = "Mail send Successfully";
}
catch
{
Label5.Visible = true;
Label5.Text = "mail sending failed";
}
}
}
No comments:
Post a Comment