View Single Post
  #1 (permalink)  
Old January 20th, 2011, 08:11 PM
Windblown Windblown is offline
Registered User
 
Join Date: Jan 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 9 - Try It OUT on page 319

Imar- Up to this point, I have been able to solve my own problems while working through your very good book. However, in Chapter 9 the Try It OUT on page 319 has me stumped. Below is my Web.Config, Code behind, and the reported error. my Email host, Username, and password(Blocked here for security) and port number are correctly entered

Any light you might be able to shed on this problem will be greatly appreciated!


Web.Config partial:

Code:
<system.net>
     <mailSettings>
         <smtp deliveryMethod="Network" from="Dan &lt;w0kks@sbcglobal.net&gt;">
           <network enableSsl="true" userName="w0kks@sbcglobal.net" 
                         password="****" host="smtp.att.yahoo.com" port="465" />
          </smtp>
      </mailSettings>
</system.net>

Code Behind for Demos/Email.aspx:

Code:
Imports System.Net.Mail
Partial Class Demos_Email
    Inherits BasePage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim myMessage As MailMessage = New MailMessage
        myMessage.Subject = "Test Message"
        myMessage.Body = "Hello World, from Planet Wrox"
        myMessage.From = New MailAddress("w0kks@sbcglobal.net", "Dan")
        myMessage.To.Add(New MailAddress("w0kks@sbcglobal.net", "Dan"))
        
        Dim mySmtpClient As SmtpClient = New SmtpClient
        mySmtpClient.Send(myMessage)

    End Sub
End Class


Reported error by WebBrowser
Server Error in '/' Application.
--------------------------------------------------------------------------------

An existing connection was forcibly closed by the remote host
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.SocketException: An existing connection was forcibly closed by the remote host

Source Error:


Line 11:
Line 12: Dim mySmtpClient As SmtpClient = New SmtpClient
Line 13: mySmtpClient.Send(myMessage)
Line 14:
Line 15: End Sub


Source File: C:\BegASPNET\Site\Demos\Email.aspx.vb Line: 13

Stack Trace:


[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6132200
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +134

[IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +300
System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count) +45
System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count) +105
System.Net.Mail.SmtpReplyReaderFactory.ReadLines(S mtpReplyReader caller, Boolean oneLine) +248
System.Net.Mail.SmtpReplyReaderFactory.ReadLine(Sm tpReplyReader caller) +16
System.Net.Mail.SmtpConnection.GetConnection(Servi cePoint servicePoint) +665
System.Net.Mail.SmtpTransport.GetConnection(Servic ePoint servicePoint) +170
System.Net.Mail.SmtpClient.GetConnection() +50
System.Net.Mail.SmtpClient.Send(MailMessage message) +1484

[SmtpException: Failure sending mail.]
System.Net.Mail.SmtpClient.Send(MailMessage message) +1811
Demos_Email.Page_Load(Object sender, EventArgs e) in C:\BegASPNET\Site\Demos\Email.aspx.vb:13
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207