sending email

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2007
Posts: 32
Reputation: sibotho is an unknown quantity at this point 
Solved Threads: 0
sibotho's Avatar
sibotho sibotho is offline Offline
Light Poster

sending email

 
0
  #1
May 18th, 2007
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.





Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 18
Reputation: NET-Developer is an unknown quantity at this point 
Solved Threads: 1
NET-Developer NET-Developer is offline Offline
Newbie Poster

Re: sending email

 
0
  #2
May 18th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 32
Reputation: sibotho is an unknown quantity at this point 
Solved Threads: 0
sibotho's Avatar
sibotho sibotho is offline Offline
Light Poster

Re: sending email

 
0
  #3
May 18th, 2007
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();
}
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 18
Reputation: NET-Developer is an unknown quantity at this point 
Solved Threads: 1
NET-Developer NET-Developer is offline Offline
Newbie Poster

Re: sending email

 
0
  #4
May 18th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC