944,081 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 8290
  • ASP.NET RSS
May 18th, 2007
0

sending email

Expand Post »
Hi all

I have been trying to send email from my asp.net website using c#. the code runs without any errors, but when i click the send button i get this error.

/*System.Net.Mail.SmtpException: Failure sending mail.---> System.Net.WebException: Unable to connect to remote server -->System.net.sockets.socketException: 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
at System.Net.Sockets.Socket.EndConnect(IAsyscResult asyncResult)*/

------------------------------------------------------------------

I heard that McAffee OAS blocks emails from going out but i have disabled it in my computer. Can you please help in eliminating this error.





Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
sibotho is offline Offline
32 posts
since Mar 2007
May 18th, 2007
0

Re: sending email

Check, if your mail client is created in this way ?

System.Net.Mail.SmtpClient mailClient = new SmtpClient("your.smtp.server", 25);
System.Net.NetworkCredential nc = new System.Net.NetworkCredential("YourLogin", "YourPassword");
mailClient.Credentials = nc;

And also check address of your SMTP server, login and password, if they are all correct. Or there may be also problems at server side.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
NET-Developer is offline Offline
18 posts
since May 2007
May 18th, 2007
0

Re: sending email

here is the code i used

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add(emailAddTextBox.Text);
message.Subject = "Testing";
message.From = new System.Net.Mail.MailAddress("myusername@gmail.com");
message.Body = "Just Testing";
 
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com",25);

 
SmtpClient client = new SmtpClient();
smtp.Credentials = new System.Net.NetworkCredential("myusername", "mypassword");
smtp.Port = 587; 
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;

 
try
{
smtp.Send(message);
}
catch (Exception exmail)
{
flightNameLabel.Text = "The email cannot be sent" + exmail.ToString();
}
Reputation Points: 10
Solved Threads: 0
Light Poster
sibotho is offline Offline
32 posts
since Mar 2007
May 18th, 2007
0

Re: sending email

But are you sure that smtp.Port must be 587 but not 25 ? Usually SMTP port is 25 (that is why I have prescribed 25 in SmtpClient constructor). If it is 587, then replace 25 into 587 in that line. Try also with smtp.EnableSsi = false.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
NET-Developer is offline Offline
18 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: How to Include framework with st up project
Next Thread in ASP.NET Forum Timeline: Connection to database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC