SmtpClient.BindEndPoint Property


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

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

Property Value

A valid IP address network endpoint.

Remarks

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.

Example

[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()
    
    Try
        Dim oServer As SmtpServer = New SmtpServer("myserveraddress")
        
        Dim oMail As SmtpMail = New SmtpMail("TryIt")
        oMail.From = New MailAddress("from@adminsystem.com")
        oMail.To.Add(New MailAddress("to@adminsystem.com"))
        
        oMail.Subject = "test subject"
        oMail.TextBody = "test email with IP binding"

        Dim oSmtp As SmtpClient = New SmtpClient()

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