如何通过C#中的代理服务器发送电子邮件

时间:2012-11-07 11:46:19

标签: asp.net email c#-4.0 proxy smtp

您好我想用ASP.NET发送邮件, 但我想通过代理服务器发送电子邮件, 那么我应该如何编辑下面的代码以通过代理服务器发送它?

由于

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new  SmtpClient(ConfigurationManager.AppSettings["MailServer"]);
mail.From = new MailAddress(ConfigurationManager.AppSettings["MailAccount"]);
mail.To.Add(toAddres);
mail.CC.Add(new MailAddress(ccAddress));
mail.Subject = subject;
mail.Body = content;
mail.IsBodyHtml = true;
SmtpServer.Port = ConfigurationManager.AppSettings["MailPort"] == null ? 587 : int.Parse(ConfigurationManager.AppSettings["MailPort"]);
SmtpServer.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["MailUserName"], ConfigurationManager.AppSettings["MailPassword"]);
SmtpServer.EnableSsl = false;
SmtpServer.Send(mail);

0 个答案:

没有答案