G
Guest
Hi,
I have created a windows application to send emails using vs 2005 in
vb.net. I am having problems sending the emails. The operating system on
which this application is run is windows vista business. we have an exchange
server 2007 that is in the same network. I am trying to send the emails using
the exchange server with the following code.
Private Sub btnSendEmail_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSendEmail.Click
Dim errMsg As String
Dim ToAddress As String
Dim FromAddress As String
'Dim mailman As New Chilkat.MailMan
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.Host = "exchangeserver ip address"
smtp.Port = 25
'smtp.se()
smtp.Credentials = New
System.Net.NetworkCredential("exchangeserveripaddress\myusername",
"mypassword")
smtp.UseDefaultCredentials = False
smtp.DeliveryMethod = SmtpDeliveryMethod.Network
Try
smtp.Send(mm)
Catch ex As Exception
errMsg = ex.ToString()
End Try
Catch ex As Exception
End Try
Following is the error that I am receiving when I run the code.
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: No connection could be made because the
target machine actively refused it
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState
state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream,
Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket&
abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async,
Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject,
GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject,
GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at WindowsApplication1.Form1.btnSendEmail_Click(Object sender, EventArgs
e) in C:\Users\sduggireddy\Documents\Visual Studio
2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb:line 162
I am not knowing how to debug this. Please let me know.
Thanks
I have created a windows application to send emails using vs 2005 in
vb.net. I am having problems sending the emails. The operating system on
which this application is run is windows vista business. we have an exchange
server 2007 that is in the same network. I am trying to send the emails using
the exchange server with the following code.
Private Sub btnSendEmail_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSendEmail.Click
Dim errMsg As String
Dim ToAddress As String
Dim FromAddress As String
'Dim mailman As New Chilkat.MailMan
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.Host = "exchangeserver ip address"
smtp.Port = 25
'smtp.se()
smtp.Credentials = New
System.Net.NetworkCredential("exchangeserveripaddress\myusername",
"mypassword")
smtp.UseDefaultCredentials = False
smtp.DeliveryMethod = SmtpDeliveryMethod.Network
Try
smtp.Send(mm)
Catch ex As Exception
errMsg = ex.ToString()
End Try
Catch ex As Exception
End Try
Following is the error that I am receiving when I run the code.
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: No connection could be made because the
target machine actively refused it
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState
state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream,
Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket&
abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async,
Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject,
GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject,
GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at WindowsApplication1.Form1.btnSendEmail_Click(Object sender, EventArgs
e) in C:\Users\sduggireddy\Documents\Visual Studio
2005\Projects\WindowsApplication1\WindowsApplication1\Form1.vb:line 162
I am not knowing how to debug this. Please let me know.
Thanks