通过代理设置发送电子邮件 [英] Sending e-mail through proxy setting
本文介绍了通过代理设置发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个必须发送电子邮件的应用程序.
当我具有直接的Internet连接时,我可以发送电子邮件,但是在我的LAN中提供了代理.
虽然我必须发送电子邮件.
请帮助我通过代理服务器发送邮件.
注意:
我使用c#.net.
这是我使用的一段代码:
Hi,
I am developing an application in which I have to send e-mail.
I am able to send e-mail when I have direct internet connection, but I am provided with proxy in my LAN.
Though I have to send email.
Please help me in send mail via proxy server.
Note:
I use c#.net.
Here is a piece of code that I use:
string msgSubject = txtSubject.Text.Trim();
string FrommailId = txtFrom.Text.ToString();
string TomailId = txtTo.Text.ToString();
string mailPassword = "password";
string mailServer = txtMailServer.Text.Trim();
System.Net.Mail.MailMessage objMessage = new MailMessage();
objMessage.To.Add(TomailId);//Set To address
objMessage.From = new MailAddress(FrommailId, "From", System.Text.Encoding.UTF8);//Set From address
objMessage.Subject = msgSubject;//Set Subject
objMessage.SubjectEncoding = System.Text.Encoding.UTF8;
objMessage.Body = txtMessage.Text.Trim();
objMessage.BodyEncoding = System.Text.Encoding.UTF8;
objMessage.IsBodyHtml = false;
objMessage.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(FrommailId, mailPassword);//Set UserName and Password for Network authendication
client.Port = Convert.ToInt32(txtPortNo.Text.Trim());//Port for sending mail
client.Host = mailServer;//587 For smtp.gmail.com
client.EnableSsl = true;
client.Send(objMessage);
[edit]已添加代码块,忽略HTML ..."选项已禁用-OriginalGriff [/edit]
[edit]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]
推荐答案
hi
检查以下链接
http://www.atp-inc.net/doc/mail/Connecting_through_a_proxy_server3.html [ ^ ]
http://support.microsoft.com/kb/310233 [ http://www.lesnikowski.com/blog/index .php/imap-pop3-smtp-via-http-socks-proxy/ [
hi
check below links
http://www.atp-inc.net/doc/mail/Connecting_through_a_proxy_server3.html[^]
http://support.microsoft.com/kb/310233[^]
http://www.lesnikowski.com/blog/index.php/imap-pop3-smtp-via-http-socks-proxy/[^]
hope it will work
这篇关于通过代理设置发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文