SmtpClient.BindEndPoint Property

Gets or sets the local IP address binding for sending email.

[Visual Basic]
Public Property BindEndPoint As System.NET.EndPoint
public System.NET.EndPoint BindEndPoint {get; set;}
public: __property System.NET.EndPoint^ get_BindEndPoint();
public: __property void set_BindEndPoint(System.NET.EndPoint^);
public function get BindEndPoint() : System.NET.EndPoint;
public function set BindEndPoint(System.NET.EndPoint);

Property Value

A valid IP address network endpoint.


By default, SmtpClient uses the default IP address of current machine to send email. However, if there are mulitple IP addresses on current machine, you can specify one of IP address to bind and send the email.


[Visual Basic] To get the full samples of EASendMail, please refer to Samples section.

[VB - Send Email with IP address binding]
Imports EASendMail
Imports System.Net
Sub SendMail()
    Dim oMail As SmtpMail = New SmtpMail("TryIt")
    Dim oSmtp As SmtpClient = New SmtpClient

        Dim oServer As SmtpServer = New SmtpServer("myserveraddress")
        oMail.From = New MailAddress("")
        oMail.To.Add(New MailAddress(""))
        oMail.Subject = "test subject"
        oMail.TextBody = "test email with IP binding"
        oSmtp.BindEndPoint = New IPEndPoint(IPAddress.Parse(""), 0 )
        oSmtp.SendMail( oServer, oMail )
        Console.WriteLine( "message was sent" )
    Catch exp As SmtpTerminatedException
    Catch exp As SmtpServerException
        Console.WriteLine("Exception: Server Respond: {0}", exp.ErrorMessage)
    Catch exp As System.Net.Sockets.SocketException
        Console.WriteLine("Exception: Networking Error: {0} {1}", exp.ErrorCode, exp.Message)
    Catch exp As System.ComponentModel.Win32Exception
        Console.WriteLine("Exception: System Error: {0} {1}", exp.ErrorCode, exp.Message)
    Catch exp As System.Exception
        Console.WriteLine("Exception: Common: {0}", exp.Message)
    End Try

    Console.WriteLine("SMTP LOG:" & vbCrLf)
End Sub