private string servicePointIP;
public string ServicePointIP
{
get { return servicePointIP; }
set { servicePointIP = value; }
}
public delegate IPEndPoint BindIPEndPoint(ServicePoint servicePoint,
IPEndPoint remoteEndPoint, int retryCount);
private IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint,
IPEndPoint remoteEndPoint, int retryCount)
{
Console.WriteLine("BindIPEndPoint Called");
if (retryCount < 3 && servicePointIP != null)
return new IPEndPoint(IPAddress.Parse(servicePointIP), 0);
else
return new IPEndPoint(IPAddress.Any, 0);
}
private string SendMail(MailMessage msg, IPAddress ip)
{
servicePointIP = "192.168.1.9";
SmtpClient smtp = new SmtpClient();
smtp.Host = "localhost";
smtp.Port = 25;
smtp.ServicePoint.BindIPEndPointDelegate = new System.Net.BindIPEndPoint(BindIPEndPointCallback);
smtp.Send(msg);
}
|