Ad

Friday, July 26, 2013

Mail Sending Code in Asp.Net

Overview:
In this Article i would Like to publish an article on Mail Sending in Asp.Net



Description:


Using The Name Space of

Using System.Net.Mail

Code: 



using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
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)
    {
        MailMessage m = new MailMessage();
        m.To.Add(TextBox1.Text);
        m.From = new MailAddress("pvasanthkumar5@gmail.com");
        m.IsBodyHtml = true;
        m.Subject = TextBox2.Text;
        m.Body = ""+TextBox3.Text+"
"
;
        SmtpClient s = new SmtpClient();
        s.Host = "smtp.gmail.com";
        s.Port = 587;
        s.Credentials = new System.Net.NetworkCredential
                 ("pvasanthkumar5@gmail.com", "enterurpassword");
        s.EnableSsl = true;
        s.Send(m);
        Response.Write("");

    }
}

    }
}

OutPut:

 

No comments: