0

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>");
2
Contributors
1
Reply
4
Views
4 Years
Discussion Span
Last Post by MARKAND911
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.