所以我写了这个程序来发送一组我的朋友的短信。 当我在工作中尝试使用它时无法正常工作,它在家中正常工作。我收到一条错误消息“发送邮件失败”。代理正在阻止我的程序连接到互联网
我们在工作中使用了一个拦截代理。我虽然/希望一切都会奏效,但显然不是。
那么我需要做什么,我从来没有编程通过代理连接/发送流量。
我使用C#和SmtpClient类来发送消息。 这里有一个小片段。
SmtpClient client = new SmtpClient(emailType.Address, emailType.Port);
client.Credentials = new System.Net.NetworkCredential(tbxAccountUser.Text, tbxUserPassword.Text);
client.Send(message);
我跟我们的IT部门交谈过,我有他们正在使用的IP,但我不确定我需要什么。我甚至不能确定使用什么类...
我尝试这样做:
的WebRequest myWebRequest = WebRequest.Create( “http://www.google.com”); WebProxy myProxy = new WebProxy(); //获取默认浏览器的代理属性。
myProxy =(WebProxy)myWebRequest.Proxy;
Uri newUri = new Uri("http://"+ ip +":8080");
// Associate the new Uri object to the myProxy object.
myProxy.Address = newUri;
// Create a NetworkCredential object and is assign to the Credentials property of the Proxy object.
myProxy.Credentials = new NetworkCredential(userName, passWd);
myWebRequest.Proxy = myProxy;
我不确定是否可以将它设置为我的SmtpClient客户端?
谢谢