This is the code that i have used for sending an E- mail: But the E-mail sending is getting failed every time plz give your valuable suggestions to solve this problem it's Urgent thanxx.....
    MailMessage mail = new MailMessage();
    mail.To.Add("yash.work19@gmail.com");
    mail.From = new MailAddress("yshshkl@gmail.com");
    mail.Subject = "hello";
    mail.Body = "good one";
    mail.IsBodyHtml = true;
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address

    smtp.Port = 465; //also tried 587
    smtp.Credentials = new System.Net.NetworkCredential
    ("yshshkl@gmail.com", "***********");  //my id and password      
    smtp.EnableSsl = false;
    smtp.Send(mail);
    Response.Write("<script language='javascript'>alert('MAIL SENT');</script>");

I think there is no need to assign the port.
It might work.
Comment the following code

smtp.port=465;

and then try to send.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.