如题,本地有多个IP地址,如何使用不同的IP地址发送邮件,没看到相应的API
使用 SmtpClient.ServicePoint.BindIPEndPointDelegate
http://msdn.microsoft.com/en-us/library/system.net.servicepoint.bindipendpointdelegate.aspx
var smtpClient = new SmtpClient(...);
smtpClient.ServicePoint.BindIPEndPointDelegate = (servicePoint, remoteEndPoint, retryCount) =>
new IPEndPoint( IPAddress.Parse( "YOUR LOCAL ADDRESS" ), 0 );