469,950 Members | 2,336 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Emailing Troubles

Frinavale
9,735 Expert Mod 8TB
Platform: Windows XP Pro
Language: ASP/VB.Net

Hi there,
I am trying to send an email from a remote email server that requires email authentication (requires credentials to log into the webserver in order to send the email).
I have encountered the following error while trying to send an email:

"SocketException (0x274d): No connection could be made because the target machine actively refused it."

The code that generates the error is:

Expand|Select|Wrap|Line Numbers
  1.    Dim retval As Boolean
  2.    retval = False
  3.    Dim emailMessage As Net.Mail.MailMessage
  4.    Dim body As String = compileEmailMessage()
  5.  
  6.    emailMessage = New Net.Mail.MailMessage("FromEmail@email.ca", "ToEmail@email.ca", "Title", body)
  7.  
  8.     Dim mailClient As New Net.Mail.SmtpClient
  9.     Dim myCredentials As New System.Net.NetworkCredential("me@TheMailServer.ca", "******")
  10.  
  11.      mailClient.Host = "mail.MyMailServer.ca"
  12.      mailClient.UseDefaultCredentials = False
  13.      mailClient.Credentials = myCredentials
  14.     Try
  15.           mailClient.Send(emailMessage)  '<-----Crashes on this line
  16.           retval = True
  17.      Catch ex As Exception
  18.            retval = False
  19.           lbl_debug.text = ex.Message + " " + ex.StackTrace
  20.      End Try
  21.  
Has anyone seen this error before or have any comments on how I could fix this error?

Thanks a lot for your help.
-F
Dec 18 '06 #1
2 1939
Frinavale
9,735 Expert Mod 8TB
Platform: Windows XP Pro
Language: ASP/VB.Net

Hi there,
I am trying to send an email from a remote email server that requires email authentication (requires credentials to log into the webserver in order to send the email).
I have encountered the following error while trying to send an email:

"SocketException (0x274d): No connection could be made because the target machine actively refused it."

The code that generates the error is:

Expand|Select|Wrap|Line Numbers
  1.    Dim retval As Boolean
  2.    retval = False
  3.    Dim emailMessage As Net.Mail.MailMessage
  4.    Dim body As String = compileEmailMessage()
  5.  
  6.    emailMessage = New Net.Mail.MailMessage("FromEmail@email.ca", "ToEmail@email.ca", "Title", body)
  7.  
  8.     Dim mailClient As New Net.Mail.SmtpClient
  9.     Dim myCredentials As New System.Net.NetworkCredential("me@TheMailServer.ca", "******")
  10.  
  11.      mailClient.Host = "mail.MyMailServer.ca"
  12.      mailClient.UseDefaultCredentials = False
  13.      mailClient.Credentials = myCredentials
  14.     Try
  15.           mailClient.Send(emailMessage)  '<-----Crashes on this line
  16.           retval = True
  17.      Catch ex As Exception
  18.            retval = False
  19.           lbl_debug.text = ex.Message + " " + ex.StackTrace
  20.      End Try
  21.  
Has anyone seen this error before or have any comments on how I could fix this error?

Thanks a lot for your help.
-F
I figured it out thanks. I found out that the mail server doesn't run on the default port. Once I supplied the port everything worked fine.

:)

-F
Dec 18 '06 #2
sashi
1,754 Expert 1GB
I figured it out thanks. I found out that the mail server doesn't run on the default port. Once I supplied the port everything worked fine.

:)

-F
Hi there,

Congrats on your discovery :) Good luck & Take care.
Dec 19 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Stanley Cheung | last post: by
2 posts views Thread by Stanley Cheung | last post: by
4 posts views Thread by Mike Moore | last post: by
1 post views Thread by Stanley Cheung | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.