unable to connect to the remote server while sending email

G

Guest

Hi,

I have created a windows application to send the emails. Following is the
code I am using.

Dim errMsg As String
Dim ToAddress As String
Dim FromAddress As String
Try
ToAddress = "(e-mail address removed)"
FromAddress = "(e-mail address removed)"
Dim mm As New MailMessage(FromAddress, ToAddress)

mm.Subject = "Test"
mm.Body = "Test Email"
mm.IsBodyHtml = False

Dim smtp As New SmtpClient
smtp.Send(mm)

Catch ex As Exception
errMsg = ex.InnerException.Message
End Try

In the app.config I specified
<system.net>
<mailSettings>
<smtp>
<network host ="myexchangeserveripaddress" />
</smtp>
</mailSettings>
</system.net>

I am running this code on windows vista. I am not sure if that is the issue.
If so how could I resolve that?

Thanks,
 
R

Rad [Visual C# MVP]

Hi,

I have created a windows application to send the emails. Following is the
code I am using.

Dim errMsg As String
Dim ToAddress As String
Dim FromAddress As String
Try
ToAddress = "(e-mail address removed)"
FromAddress = "(e-mail address removed)"
Dim mm As New MailMessage(FromAddress, ToAddress)

mm.Subject = "Test"
mm.Body = "Test Email"
mm.IsBodyHtml = False

Dim smtp As New SmtpClient
smtp.Send(mm)

Catch ex As Exception
errMsg = ex.InnerException.Message
End Try

In the app.config I specified
<system.net>
<mailSettings>
<smtp>
<network host ="myexchangeserveripaddress" />
</smtp>
</mailSettings>
</system.net>

I am running this code on windows vista. I am not sure if that is the issue.
If so how could I resolve that?

Thanks,

What is the problem? You'd get more (and better) assistance if you
specify what your problem is.
 
G

Guest

I put the error message in the subject. This is the detailed error message

System.Net.Mail.SmtpException - Failure sending mail.
InnerException - Unable to connect to Remote server.
No Connection could be made because the target machine actively
refused it.

Thanks,
 
R

Rad [Visual C# MVP]

I put the error message in the subject. This is the detailed error message

System.Net.Mail.SmtpException - Failure sending mail.
InnerException - Unable to connect to Remote server.
No Connection could be made because the target machine actively
refused it.

Ah, I missed that.

With regards to your smtp server, perhaps it requires authentication?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top