Smtp.NET 3 Documentation

SmtpServer.ServerAddress Property

SMTP mail server addresses, e.g. or Separate multiple servers with a comma, e.g.,,localhost, etc.

[Visual Basic]
Public Property ServerAddress As String
public string ServerAddress {get; set;}

Property Value

A string that specifies one or more mail server addresses seperated by a comma.


If this property is not set, "localhost" is assumed. When multiple servers are specified, each additional server is used in the event that the object is unable to connect to the first mail server.


            public void Send()
                 SmtpServer oSmtpDotNet = new SmtpServer();
                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "localhost,,";
                 // Message Addressing
                 oSmtpDotNet.ToAddress = "";
                 oSmtpDotNet.FromAddress = "";
                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";
                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                      Console.WriteLine("Error #"+nRC+" occurred.");
                 // Success!
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes
                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "localhost,,"
                 ' Message Addressing
                 oSmtpDotNet.FromAddress = ""
                 oSmtpDotNet.ToAddress = ""
                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"
                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     ' Write out the log file contents
                     Exit Function
                 End If
                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace