Thursday, March 20, 2014

Mail sending code for asp.net


using System.Net.Mail;
using System.Net;

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

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SmtpClient smtpc = new SmtpClient("smtp.gmail.com");
        smtpc.Port = 587;
        smtpc.EnableSsl = true;
        smtpc.UseDefaultCredentials = false;
        smtpc.Credentials = new NetworkCredential(TextBox1.Text, TextBox2.Text);
        MailMessage email = new MailMessage(TextBox1.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text);
        try
        {
            smtpc.Send(email);
            Label1.Text = "Message has been successfully send";
        }
        catch
        {
       Label1.Text= "server authentication is faild,check your id and password";
        }
    }
}



Description:- In above example,First i have include two Namespace to use the mail service in ASP.NET Application.
  • using System.Net.Mail;
  • using System.Net;
After that i have created a Smtpclient class object (smtpc) and passed the Smtp server name and port Number  to the Smtpclient. After that  i have passed the our credential information to the Network through Smtpclient object(smtpc). After that i have created a MailMessage class object(email) and passed sender mail address,  destination mail address,subject,message body to the MailMessage class. After that send the mail message through Smtpclient object(smtpc) as shown in  above codes.

Sunday, March 2, 2014

-: CODE FOR ON LINE SEARCH :-

CODE FOR ON LINE  SEARCHING IN YOUR WEB PAGE



<html>
<head>
</head>
<body>
<form method="get"action="http://www.google.com/search">
<input type="text" name="q" size="30" x-webkit-speech >
<input type="submit" value="search">
</form>

</body>
</html>

JDBC  Connectivity With MySQL