EDN Admin
Well-known member
Hi,
I am trying to make an application to send email. It actually throws an error stating SmtpException was unhandled, Failure sending email.
error code: 10060
My code is as follows:
namespace SendMail
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnSendMail_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To.Add(txtBoxMailID.Text);
mail.From = new MailAddress("anshumansingh@gmail.com", "Anshuman Singh");
mail.Body = "Hi, This mail is from my application n -- Anshu";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("anshumansingh", "mypass");
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = true;
Attachment attachment = new Attachment(@"G:Mail.txt");
mail.Attachments.Add(attachment);
smtp.Send(mail);
MessageBox.Show("Hurray!! n Mail Sent");
}
}
}
Error Details:
Message:
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 72.14.213.109:587
Stack Trace:
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
Any help will be great.
Thanks,
Anshu
View the full article
I am trying to make an application to send email. It actually throws an error stating SmtpException was unhandled, Failure sending email.
error code: 10060
My code is as follows:
namespace SendMail
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnSendMail_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To.Add(txtBoxMailID.Text);
mail.From = new MailAddress("anshumansingh@gmail.com", "Anshuman Singh");
mail.Body = "Hi, This mail is from my application n -- Anshu";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("anshumansingh", "mypass");
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = true;
Attachment attachment = new Attachment(@"G:Mail.txt");
mail.Attachments.Add(attachment);
smtp.Send(mail);
MessageBox.Show("Hurray!! n Mail Sent");
}
}
}
Error Details:
Message:
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 72.14.213.109:587
Stack Trace:
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
Any help will be great.
Thanks,
Anshu
View the full article