i am trying to implement this in my application to send a mail but i keep getting this error i configured in my web.config
<system.net>
<mailSettings>
<smtp from="dep-it@public-health.gov.lb" deliveryMethod="Network">
<network host="mail.ogero.gov.lb" password="" userName="" port="25" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
and this is the code i'm using :
Public Function SendMail(ByVal strTo As String, ByVal strSubject As String, ByVal strMsg As String, ByVal path As String) As Boolean
'ByVal strFrom As String,
Try
' Create the mail message
Dim objMailMsg As MailMessage = New MailMessage("dep-it@publichealth.gov.lb", strTo)
objMailMsg.BodyEncoding = Encoding.UTF8
objMailMsg.Subject = strSubject
objMailMsg.Body = strMsg
objMailMsg.Priority = MailPriority.High
objMailMsg.IsBodyHtml = True
'prepare to send mail via SMTP transport
Dim objSMTPClient As SmtpClient = New SmtpClient()
'objSMTPClient.EnableSsl = True
objSMTPClient.Credentials = CredentialCache.DefaultNetworkCredentials
objSMTPClient.UseDefaultCredentials = True
objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.Network
objSMTPClient.Send(objMailMsg)
Return True
Catch ex As Exception
Client_Alert(ex.ToString)
End Try
End Function
it keeps giving this error :
System.Net.Mail.SmtpException was caught
Message="Failure sending mail."
Source="System"
StackTrace:
at System.Net.Mail.SmtpClient.Send(MailMessage message) at WebOracle.mails.SendMail(String strTo, String strSubject, String strMsg, String path) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\WebOracle\mails.aspx.vb:line 57
InnerException: System.Net.WebException
Message="Unable to connect to the remote server"
Source="System"
StackTrace:
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)
InnerException: System.Net.Sockets.SocketException
ErrorCode=10065
Message="A socket operation was attempted to an unreachable host 205.177.180.20:25"
NativeErrorCode=10065
Source="System"
StackTrace:
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)
Does anyone have ideas??