Re: sending an email from windows application .net 2.0

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Ged,

Thanks for the reply. I am sure that our exchange server will allow to
send emails through smtp. We have a .net 1.1 windows application which uses
chilkat.net dll to send the emails. when i looked at the code, I saw that we
are setting a property smtphost. so I think our exchange server 2007 will
send emails via smtp.

Regarding the exchange server using port 25 I tested this using telnet. when
I do telnet exchangeipaddress 25 it is connected. but I did this test on
another machine. when I do the same test on my computer it says "could not
opeb connection to the host on port 25"

Like I said before I am using windows vista business edition. I am thinking
that the firewall is blocking it or something like that. I am not knowing how
to unblock.

Please let me know.

Thanks,

"Ged" wrote:

Hi Sridhar

Looking at the error stack, the line

"System.Net.Sockets.SocketException: No connection could be made because the
target machine actively refused it"

sticks out for me.

So, a couple of questions.

1. Does the exchange server allow you to send using SMTP ?
2. Is Exchange listening on port 25 ?
3. Are your credentials correct?

I would get a standard mail client (i.e. Windows Mail, Thunderbird etc) and
see if it can send email via exchange server using SMTP.


--
Ged Moretta
www.appsense.com

-----------------------------------------------------------------------
This signature isn't automatic. I have to type it manually every time.


"Sridhar" <Sridhar@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:103168A6-4032-48C0-A284-44A458985C30@xxxxxxxxxxxxxxxx
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 = "to@xxxxxxxxxxxxx"
FromAddress = "from@xxxxxxxxxxxxx"
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


.



Relevant Pages

  • Re: Routing emails
    ... Then create another SMTP Connector and put the particular domain in as the ... wanting to find out how to send emails at the zyx.com exchange server ...
    (microsoft.public.exchange.misc)
  • Re: Unable to send large emails NDR 5.2.3
    ... MIME conversion I am able to send 8mb emails through. ... Exchange Server 2007: Setting Message Size Limits ... Routing Groups: SMTP Connector ...
    (microsoft.public.exchange.admin)
  • Unable to send large emails NDR 5.2.3
    ... The sender receives an NDR from my exchange server of 5.2.3 ... Routing Groups: SMTP Connector ... I have tested extensively by sending myself emails from hotmail and gmail ...
    (microsoft.public.exchange.admin)
  • Cant get new accounts to work
    ... It is the only Exchange server in our ... until I just rebuilt the Recipient Update Service. ... smtp addresses would not show up before in Outlook. ... emails and not get the new department emails. ...
    (microsoft.public.exchange2000.general)
  • Using ASP to send email with CDO
    ... On my test system, which is a Windows ... 2000 server without exchange - just a vanillia default installation SMTP ... up with exchange server as part of the SBS and IIS for their web server. ... I believe CDO uses SMTP. ...
    (microsoft.public.exchange.applications)