I want to send email to C # via SMTP to other mail providers, for example Gmail, Yahoo, AOL, Msn, Live, etc., so that my code works fine if my computer is connected to the Internet through a proxy or connected directly to the Internet . (A proxy is a direct proxy server that accepts requests from the internal network and sends them to the Internet, and I configure the proxy server in IE as)
.................... .............
I have a code by which I can send SMTP mail if the PC is not connected through a proxy
public void SendMail(string senderId, string password, List<string> To, List<string> CC, List<string> BCC, string Subject, string Body, List<Attachment> Attachment)
{
SmtpClient SmtpServer = null;
string[] ss = senderId.Split('@');
string ServerName = ss[1].Substring(0, ss[1].IndexOf("."));
switch (ServerName.ToLower())
{
case "gmail":
SmtpServer = new SmtpClient("smtp.gmail.com");
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential(senderId, password);
SmtpServer.EnableSsl = true;
break;
case "msn":
case "live":
case "hotmail":
case "outlook":
SmtpServer = new SmtpClient("smtp.live.com");
SmtpServer.Port = 25;
SmtpServer.Credentials = new System.Net.NetworkCredential(senderId, password);
SmtpServer.EnableSsl = true;
break;
case "aol":
SmtpServer = new SmtpClient("smtp.aol.com");
SmtpServer.Port = 25;
SmtpServer.Credentials = new System.Net.NetworkCredential(senderId, password);
SmtpServer.EnableSsl = true;
break;
case "yahoo":
case "ymail":
case "rocketmail":
case "yahoomail":
SmtpServer = new SmtpClient("smtp.mail.yahoo.com");
SmtpServer.Port = 25;
SmtpServer.Credentials = new System.Net.NetworkCredential(senderId, password);
SmtpServer.EnableSsl = false;
break;
default:
break;
}
SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mail = new MailMessage();
mail.From = new MailAddress(senderId);
foreach (string item in To)
{
mail.To.Add(item);
}
foreach (string item in CC)
{
mail.CC.Add(item);
}
foreach (string item in BCC)
{
mail.Bcc.Add(item);
}
mail.Subject = Subject;
mail.Body = Body;
foreach (Attachment item in Attachment)
{
mail.Attachments.Add(item);
}
SmtpServer.Send(mail);
}
This works fine, but I want to send an email when connecting through a proxy.
,
-
ASP.net SMTP Mail -
.NET PROXY?
, , chilkat, limilabs, , -.
, SOCKS, , SMTP , -, .
- , , -, - , ?
EDIT: - , , Chilkat limilabs, > dll