How to use http proxy while sending email via SmtpClient [duplicate]

旧城冷巷雨未停 提交于 2019-11-29 17:34:52
Avram Tudor
System.Net.GlobalProxySelection.Select = new WebProxy(address,port);

Update: System.Net.GlobalProxySelection.Select has been deprecated

If you use it you will get a warning:

This class has been deprecated. Please use WebRequest.DefaultWebProxy instead to access and set the global default proxy. Use 'null' instead of GetEmptyWebProxy. http://go.microsoft.com/fwlink/?linkid=14202

Use this instead:

WebRequest.DefaultWebProxy = new WebProxy(address,port);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!