I am trying to send email with help of my web page. I am using my Gmail id for that. I am getting error :
A connection attempt failed because the connected party did not properly respond after
a period of time, or established connection failed because connected host has failed to
respond 74.125.129.109:25
here is my c# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
namespace sendmail
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
MailMessage Msg = new MailMessage();
Msg.From = new MailAddress("email@gmail.com");
Msg.To.Add(txtToMail.Text);
Msg.Subject = txtSubject.Text;
Msg.Body = txtMessage.Text;
Msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = "email@gmail.com";
NetworkCred.Password = "mypassword";
// smtp.Timeout = 10000;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = NetworkCred;
smtp.Port = 25;
smtp.EnableSsl = false;
smtp.Send(Msg);
lblMsg.Text = "Email has been successfully sent..!!";
}
}
}