Click here to Skip to main content
13,050,429 members (132,640 online)
Rate this:
Please Sign up or sign in to vote.
Hi I want to send mail with ASP.NET,
but I want to send email through proxy server,
So how should I edit the code below to send it through a proxy server?


MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient(ConfigurationManager.AppSettings["MailServer"]);
                mail.From = new MailAddress(ConfigurationManager.AppSettings["MailAccount"]);
                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;
Posted 7-Nov-12 0:43am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can create a Method to send the mail through proxy...

MailAddress from = new MailAddress("");
MailAddress to = new MailAddress("");
MailMessage mm = new MailMessage(from, to);
mm.Subject = "Subject"
mm.Body = "Body";
SmtpClient client = new SmtpClient("", 8080);
client.Credentials = new System.Net.NetworkCredential("", "password");

There is no need to incorporate it into your web.config at all

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100