Sending Email in ASP.NET 2.0
<p>iam trying to implement code of sending mail.i have tried the following procedure.</p>

<p>Configuration</p>

<pre><code>&lt;configuration&gt;
  &lt;!-- Add the email settings to the &lt;system.net&gt; element --&gt;
  &lt;system.net&gt;
    &lt;mailSettings&gt;
      &lt;smtp&gt;
        &lt;network 
             host="localhost" 
             port="25"
             userName="?"
             password="?" /&gt;
      &lt;/smtp&gt;
    &lt;/mailSettings&gt;
  &lt;/system.net&gt;
</code></pre>

<p>HTML</p>

<pre><code>&lt;table border="0"&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Your Email:&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;&lt;asp:TextBox runat="server" ID="UsersEmail" Columns="30"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;b&gt;Subject:&lt;/b&gt;&lt;/td&gt;
        &lt;td&gt;&lt;asp:TextBox runat="server" ID="Subject" Columns="30"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td colspan="2"&gt;
            &lt;b&gt;Body:&lt;/b&gt;&lt;br /&gt;
            &lt;asp:TextBox runat="server" ID="Body" TextMode="MultiLine" Columns="55" Rows="10"&gt;&lt;/asp:TextBox&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td colspan="2" align="center"&gt;
            &lt;asp:Button runat="server" ID="SendEmail" Text="Send Feedback" /&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>Code-behind</p>

<pre><code>protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click
    '!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS'
    Const ToAddress As String = "you@youremail.com"

    '(1) Create the MailMessage instance'
    Dim mm As New MailMessage(UsersEmail.Text, ToAddress)

    '(2) Assign the MailMessage's properties'
    mm.Subject = Subject.Text
    mm.Body = Body.Text
    mm.IsBodyHtml = False

    '(3) Create the SmtpClient object'
    Dim smtp As New SmtpClient

    '(4) Send the MailMessage (will use the Web.config settings)'
    smtp.Send(mm)
End Sub
</code></pre>

<p>but its not working. error is <strong>The transport failed to connect to the server.</strong></p>
