We are currently using VB.NET 2.0 in VS 2005 and have attempted to use the new System.Net.Mail framework to send SMTP mail. Also, our email server requires smtp authentication.
Unfortunately, we continue to receive the following error:
Server Error in '/ESB3' Application.
__________________________
__________
____
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketE
xception: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond]
System.Net.Sockets.Socket.
DoConnect(
EndPoint endPointSnapshot, SocketAddress socketAddress) +1002146
System.Net.Sockets.Socket.
InternalCo
nnect(EndP
oint remoteEP) +33
System.Net.ServicePoint.Co
nnectSocke
tInternal(
Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431
[WebException: Unable to connect to the remote server]
System.Net.ServicePoint.Ge
tConnectio
n(PooledSt
ream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +1447736
System.Net.PooledStream.Ac
tivate(Obj
ect owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +190
System.Net.PooledStream.Ac
tivate(Obj
ect owningObject, GeneralAsyncDelegate asyncCallback) +21
System.Net.ConnectionPool.
GetConnect
ion(Object
owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +318
System.Net.Mail.SmtpConnec
tion.GetCo
nnection(S
tring host, Int32 port) +227
System.Net.Mail.SmtpTransp
ort.GetCon
nection(St
ring host, Int32 port) +316
System.Net.Mail.SmtpClient
.GetConnec
tion() +42
System.Net.Mail.SmtpClient
.Send(Mail
Message message) +1485
[SmtpException: Failure sending mail.]
System.Net.Mail.SmtpClient
.Send(Mail
Message message) +2074
Modules_General_ForgotPass
word.Email
NewUnhashe
dPwd(Strin
g UserID, String UnhashedPwd, String ToAddress) +420
Modules_General_ForgotPass
word.Reque
stNewPassw
ord(String
UserID_or_Email) +559
Modules_General_ForgotPass
word.btn_R
equestNewP
wd_Click(O
bject sender, EventArgs e) +48
System.Web.UI.WebControls.
Button.OnC
lick(Event
Args e) +105
System.Web.UI.WebControls.
Button.Rai
sePostBack
Event(Stri
ng eventArgument) +107
System.Web.UI.WebControls.
Button.Sys
tem.Web.UI
.IPostBack
EventHandl
er.RaisePo
stBackEven
t(String eventArgument) +7
System.Web.UI.Page.RaisePo
stBackEven
t(IPostBac
kEventHand
ler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePo
stBackEven
t(NameValu
eCollectio
n postData) +33
System.Web.UI.Page.Process
RequestMai
n(Boolean includeStagesBeforeAsyncPo
int, Boolean includeStagesAfterAsyncPoi
nt) +5102
__________________________
__________
____
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
Here is a sanitized version of the code used to generate the email.
Dim mailMessage As Net.Mail.MailMessage = New Net.Mail.MailMessage
mailMessage.From = New Net.Mail.MailAddress("xyz@
company.co
m")
mailMessage.To.Add(New Net.Mail.MailAddress("john
.doe@compa
ny.com"))
mailmessage.Subject = "This is the subject."
mailMessage.Priority = System.Net.Mail.MailPriori
ty.High
mailMessage.IsBodyHtml = True
mailmessage.Body = <B>Hello World</B>
Dim mailClient As New System.Net.Mail.SmtpClient
("mail.com
pany.com",
25)
mailClient.Credentials = New Net.NetworkCredential("(us
ername)", "(password)")
mailClient.UseDefaultCrede
ntials = False
mailClient.Send(mailMessag
e)
mailMessage.Dispose()
Thanks in advance,
-Tim