title: The parameter 'address' cannot be an empty string. Parameter name: address
body: <p>I realize this question has come up before but the answers don't answer my question directly, I've also searched the net for the last few days.</p>
  
  <p>The problem is, I have a asp.net VB form that sends to email.. However, it comes up with the error <strong>"The parameter 'address' cannot be an empty string. Parameter name: address"</strong> when I click on Submit. But the strange thing is, it still actually sends the email through with all relevant info included.</p>
  
  <p>Anyone have any ideas as to why it's giving an error but still sending?
  I feel like it's something simple, but it's doing my head in! Let me know if you need other code snippets.</p>
  
  <p>Code Behind:</p>
  
  <pre><code>Imports System.IO
  Imports System.Net
  Imports System.Net.Mail
  
  Partial Class _default
  Inherits System.Web.UI.Page
  
  Protected Sub submitButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles submitButton.Click
  
          'send new confirmation email
      Try
  
          'create the email message
          Dim EmailMsg As New MailMessage()
  
          'set the address and subject
          EmailMsg.From = New MailAddress(emailTextBox.Text.ToString)
          EmailMsg.To.Add("myemailaddress")
          EmailMsg.Subject = "Website enquiry from " + firstnameTextBox.Text.ToString
  
          'set the content
          EmailMsg.Body = "First Name: " + firstnameTextBox.Text.ToString + "&lt;br&gt;" +
                          "Last Name: " + lastnameTextBox.Text.ToString + "&lt;br&gt;" +
                          "Reply to: " + emailTextBox.Text.ToString + "&lt;br&gt;" +
                          "Ph No.: " + phoneTextBox.Text.ToString + "&lt;br&gt;" +
                          "Dropdown value:" + DropDownList1.SelectedValue + "&lt;br&gt;" +
                          "Website Address: " + webAddressTextBox.Text.ToString + "&lt;br&gt;" +
                          "Other option: " + otherTextBox.Text.ToString
  
          EmailMsg.IsBodyHtml = True
  
          'send the message
          Dim smtp As New SmtpClient()
          smtp.Send(EmailMsg) 'uses web.config settings
  
          'if successful clear form and show success message
          firstnameTextBox.Text = String.Empty
          lastnameTextBox.Text = String.Empty
          emailTextBox.Text = String.Empty
          phoneTextBox.Text = String.Empty
          DropDownList1.SelectedValue = Val("0")
          webAddressTextBox.Text = String.Empty
          otherTextBox.Text = String.Empty
  
          lblMessage.Text = "Message sent successfully!"
  
      Catch ex As Exception
          'show error message if unsuccessful
          lblMessage.Text = ex.Message
  
      End Try
  
  End Sub
  End Class
  </code></pre>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;system.net&gt;
  &lt;mailSettings&gt;
    &lt;smtp&gt;
      &lt;network host="server" 
               port="25"
               userName="myemailaddress"
               password="mypassword"/&gt;
    &lt;/smtp&gt;
  &lt;/mailSettings&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thanks heaps in advance</p>