p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Professionals (http://p2p.wrox.com/forumdisplay.php?f=352)
-   -   Failure sending mail. (http://p2p.wrox.com/showthread.php?t=76080)

phuc2583 September 6th, 2009 10:26 PM

Failure sending mail.
Server Error in '/' Application.

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

In few day ago, my email is work fine, but today, i do not know why it does not work.
Can you give me your ideal about the issues?
Best Regards
Phuc Hoang

om_prakash September 7th, 2009 02:00 AM

If you are getting error at following line:

Then this might be connection issue.
You can try using the following command:TELNET with a "25" after the host ID or IP address (
Please check the following link which gives general troubleshooting steps for these type of issues:

phuc2583 September 7th, 2009 03:27 AM

This is the whole my code that i want to do.

Shared Function SendMail(ByVal mailFrom As MailAddress, ByVal mailTo As MailAddress, ByVal strSubject As String, ByVal strContent As String, Optional ByVal CCaddress As String = "", Optional ByVal BCCaddress As String = "") As Boolean
Dim smtpClient As New SmtpClient()
Dim message As New MailMessage()
Dim kq As Boolean
'You can specify the host name or ipaddress of your server
'Default in IIS will be localhost gsmtp185-2.google.com |gsmtp147.google.com
smtpClient.Host = "gsmtp147.google.com"
message.From = mailFrom
If CCaddress.Length > 7 Then message.CC.Add(CCaddress)
If BCCaddress.Length > 7 Then message.Bcc.Add(BCCaddress)
message.IsBodyHtml = True
message.BodyEncoding = System.Text.Encoding.UTF8
message.ReplyTo = mailFrom
message.Priority = MailPriority.High
'Message body content
message.Subject = strSubject
message.Body = strContent
'Send SMTP mail
kq = True
'Catch ex As Exception
kq = False
'End Try
Return kq
End Function

Imar September 7th, 2009 06:54 AM

Hi there,

GMail's web server requires you to use SSL. This means you need to set EnableSsl to true and use a different port number.

For more info: http://www.google.com/search?hl=en&q...t&aq=f&oq=&aqi=



phuc2583 September 7th, 2009 09:26 PM

Thanks for replying me and this is the whole my code.
I think there is something wrong on that so Can you help me how can i fix it and work fine.
it work but when i check my email box so i can not receive any letter from submit form.
Shared Function GMailSend(ByVal mailFrom As MailAddress, ByVal mailTo As MailAddress, ByVal strSubject As String, ByVal strContent As String, Optional ByVal CCaddress As String = "", Optional ByVal BCCaddress As String = "") As Boolean
Dim mail As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
Dim kq As Boolean
mail.From = mailFrom
mail.Subject = strSubject
mail.Body = strContent
mail.IsBodyHtml = True
mail.BodyEncoding = System.Text.Encoding.UTF8
mail.ReplyTo = mailFrom
If CCaddress.Length > 7 Then mail.CC.Add(CCaddress)
If BCCaddress.Length > 7 Then mail.Bcc.Add(BCCaddress)

Dim credential As System.Net.NetworkCredential = New System.Net.NetworkCredential("username@nhatrang.co m", "password")
Dim smtp As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient("smtp.gmail.com")
smtp.Credentials = credential
smtp.UseDefaultCredentials = False

smtp.EnableSsl = True
smtp.Port = 587 'also tried 587,465, 25
smtp.Host = "smtp.gmail.com"
kq = True
Catch ex As Exception
kq = False
End Try
Return kq
End Function

Thanks for all thing.
Best Regards,
Phuc Hoang

Imar September 8th, 2009 04:16 AM

Try disabling the line that sets the UseDefaultCredentials or at least move it to before you assign the Credentials property. This works fine for me:

Dim mySmtpClient As New SmtpClient("smtp.gmail.com")
mySmtpClient.Port = 587
mySmtpClient.Credentials = New NetworkCredential("Your.Account@gmail.com", " YourPassword")
mySmtpClient.EnableSsl = True

Hope this helps,


phuc2583 September 8th, 2009 08:34 PM

I have done it, it is perfectly.
Thanks for helping me
Best Wishes
Phuc Hoang

All times are GMT -4. The time now is 03:00 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.