aspNetEmail

EmailMessage.LocalEndPoint Property

The localhost endpoint to use as the network origin for sending email.

public System.Net.IPEndPoint LocalEndPoint {get; set;}

Remarks

This property is only useful if you have multiple IP on your network interface(s), and want to explicitly control the origin of the email.

Example

[C#]
            EmailMessage msg = new EmailMessage( "mail.myCompany.com");
            msg.Subject = "Order Confirmation";
            msg.To = "you@yourcompany.com";
            msg.From = "me@myCompany.com";
            
            //logging for easier troubleshooting
            msg.Logging = true;
            msg.LogPath = "c:\\email.log";
            
            //set the plain text body
            msg.Body  = "the email body contents go here...";
            
            
            //manually set the local IP that email will be sent from
            //setting the port to 0 will let the .NET framework randomly select a port
            msg.LocalEndPoint = new IPEndPoint( IPAddress.Parse( "192.168.2.2"), 0 );
            
            msg.Send();
            
[VB.NET]
            Dim msg As New EmailMessage("mail.myCompany.com")
            
            msg.Subject = "Order Confirmation"
            msg.To = "you@yourcompany.com"
            msg.From = "me@myCompany.com"
            
            'logging for easier troubleshooting
            msg.Logging = True
            msg.LogPath = "c:\email.log"
            
            'set the plain text body
            msg.Body = "the email body contents go here..."
            
            
            'manually set the local IP that email will be sent from
            'setting the port to 0 will let the .NET framework randomly select a port
            msg.LocalEndPoint = New IPEndPoint(IPAddress.Parse("192.168.2.2"), 0)
            
            msg.Send()
            

See Also

EmailMessage Class | aspNetEmail Namespace