如何在使用普通smtpclient时发送电子邮件? [英] How do I send a email while using the normal smtpclient?
问题描述
我正在尝试使用MailMessage& SmtpClient类。
然而它似乎并不支持任何代理。
我一直在阅读但我似乎无法找到我的问题的任何解决方案。
我已经尝试更改smtpclient,以便它通过代理连接但不起作用。
I'm trying to send a mail with the MailMessage & SmtpClient class.
However it looks like it doesnt support any proxies what so ever.
I've been reading around but I cant seem to find any solutions to my issue.
I've tried changing the smtpclient so that it connects through a proxy but that doesnt work.
MailAddress from = new MailAddress("emailAdress");
MailAddress to = new MailAddress("emailAdress");
MailMessage mm = new MailMessage(from, to);
mm.Subject = "Subject";
mm.Body = "Body";
SmtpClient client = new SmtpClient("124.88.67.17", 82); //This should be smtp.gmail.com or outlook etc.
client.Credentials = new System.Net.NetworkCredential("emailAdress", "password");
client.Send(mm);
MessageBox.Show("Done!");
有没有其他方法通过代理使用相同的方法发送电子邮件?
我尝试了什么:
我试过玩这些参数但是没有更改任何内容。
Is there any other ways to send a email through a proxy using the same method?
What I have tried:
I've tried playing around with the parameters but that didnt change anything.
推荐答案
SmtpClient client = new SmtpClient("124.88.67.17", 82);
client.Credentials = new System.Net.NetworkCredential("emailAdress", "password");
这两行应该引用代理而不是SMTP服务器......
These two lines should refer to the proxy and not to the SMTP server...
这篇关于如何在使用普通smtpclient时发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!