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 System.Net
Imports EASendMail

Sub SendMail()
        Dim oServer As SmtpServer = New SmtpServer("myserveraddress")
        Dim oMail As SmtpMail = New SmtpMail("TryIt")
        oMail.From = New MailAddress("")
        oMail.To.Add(New MailAddress(""))
        oMail.Subject = "test subject"
        oMail.TextBody = "test email with IP binding"

        Dim oSmtp As SmtpClient = New SmtpClient()

        oSmtp.BindEndPoint = New IPEndPoint(IPAddress.Parse(""), 0)
        oSmtp.SendMail(oServer, oMail)
        Console.WriteLine("message was sent")
    Catch exp As Exception
        Console.WriteLine("Exception: {0}", exp.Message)
    End Try
End Sub