开发者

Proxy is preventing my program from connecting to the internet

开发者 https://www.devze.com 2022-12-29 17:31 出处:网络
So I wrote this program to send a group of my friends a text message. It works fine at home when I try to use it at work it doesn\'t work.I get an error message \"Failure Sending Mail\".

So I wrote this program to send a group of my friends a text message. It works fine at home when I try to use it at work it doesn't work. I get an error message "Failure Sending Mail".

We are using a intercepting proxy at work. I though/hoped that everything would just work, clearly not.

So what do I need to do, I've never programmed to connect/send traffic through a proxy.

I'm using C# and the SmtpClient class to send the message. Here's a little snippet.

SmtpClient client = new SmtpClient(emailType.Address, emailType.Port);
client.Credentials = new System.Net.NetworkCredential(tbxAccountUser.Text, tbxUserPassword.Text);
client.Send(message);

I talked to our IT department and I have the IP that they are using but I wasn't sure what I need. I'm not even sure what class to use...

I tried this:

WebRequest myWebRequest = WebRequest.Create("http://www.google.com"); WebProxy myProxy = new WebProxy(); // Obtain the Proxy Prperty of the Default browser.

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;

Im not sure if I can s开发者_开发技巧et this to my SmtpClient client?

Thanks


I'm having the same problem. The SMTP class doesn't have a proxy property, which makes things very complicated. The only thing that comes to mind is to use WebRequest class and to send every attribute of your mail message as a single string after which you wait for response by the server (WebRequest has a proxy property). But I haven't implemented it yet. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消