title: Can't pass property value into private object's contructor
body: <p>I'm trying to create a custom smtp class using the existing System.Net.Mail.SmtpClient but somehow it's not picking up property values which was set outside of the class. </p>
  
  <pre><code>Public Class CustomClient
     Implements IDisposable
  
     Private smtpClient As System.Net.Mail.SmtpClient
  
     Public Property FromAddress As String
     Public Property ToAddress As String
     Public Property Subject As String
     Public Property Body As String
     Public Property MtaIP As String
  
     Public Sub New()
  
        Me.smtpClient = New Net.Mail.SmtpClient(MtaIP, 25) 'SmtpClient's Host field is still empty after initializationa
        smtpClient.EnableSsl = False
        smtpClient.UseDefaultCredentials = True
        smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
     End Sub
  
     Public Sub SendMessage()
       Try
          Using message As New MailMessage(FromAddress, ToAddress)
  
              message.Subject = Subject
              message.Body = "TEST"
              message.BodyTransferEncoding = Net.Mime.TransferEncoding.QuotedPrintable
              smtpClient.Send(message)
          End Using
       Catch ex As Exception
          Dim errorMsg As String = " SMTPClient encountered the following error..." &amp;
                 vbNewLine &amp; vbNewLine &amp; "Exception Information:" &amp; vbNewLine &amp; BuildExceptionReport(ex)
          CourierShared.Common.sendMessage(errorMsg, MessageTypes.Failure)
      End Try
    End Sub
  
  End Class
  </code></pre>
  
  <p>Above is my code. I confirmed MtaIP's value is correctly passed over from outside, but somehow it's throwing exception complaining hostname is not specified. When I change the property to public field instead and assign value manually, it works fine.</p>
  
  <p>Am I missing something with property usage?</p>
  
  <p>Edit: I added more specific send method in CustomClient object and below is how I use the class to send the message</p>
  
  <pre><code>Public Class CustomClientTest
    Public Sub Test()
       Using client As New CustomClient()
           client.FromAddress = inboundSender
           client.ToAddress = inboundRecipient
           client.Subject = inboundMsgSubject
           client.MtaIP = "123.234.34.56" 'I use actual host that works but put this as a reference
           client.SendMessage()
       End Using
    End Sub
  End Class
  </code></pre>