日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > asp.net >内容正文

asp.net

奇怪的问题,.Net 2.0发送邮件失败...

發(fā)布時(shí)間:2025/3/14 asp.net 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 奇怪的问题,.Net 2.0发送邮件失败... 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
.Net 1.1中發(fā)送郵件使用System.Web.Mail.而到.Net 2.0中發(fā)送郵件建議使用System.Net.Mail,不推薦使用System.Web.Mail,但是原來(lái)的還能用,今天將原來(lái)1.1發(fā)送程序改寫(xiě)成2.0,但是一直是發(fā)送失敗,一直被諾頓攔截,很奇怪,而且把諾頓Internet Email Auto Protected關(guān)閉就能發(fā)送出去.原來(lái)1.1從來(lái)沒(méi)有諾頓攔截現(xiàn)象.


根據(jù)上面的鏈接查詢Symantec Support KB,解釋如下:
1? Start Outlook Express.?
2? Click the Tools menu, and then click Accounts.?
3? In the Internet Accounts list, click the name of the account that you use to send email.?
4? Click Properties.
5? Click the Advanced tab.
6? Under Server Timeouts, drag the slider so that the number of minutes increases. The maximum time that you can set it to is 5 minutes.
7? Click OK.?
8? Click Close.

暈死,設(shè)置發(fā)送超時(shí)時(shí)間為 5 Min

但是將發(fā)送TimeOut設(shè)為5*60*1000仍然發(fā)送失敗,搞不懂了

?1public?void?SendNetSmtpMail2()
?2????????{
?3????????????System.Net.Mail.MailMessage?oMsg?=?new?System.Net.Mail.MailMessage();
?4????????????//?Set?the?message?sender
?5????????????oMsg.From?=?new?System.Net.Mail.MailAddress("upzone@126.com",?"upzone");
?6????????????//?The?.To?property?is?a?generic?collection,?
?7????????????//?so?we?can?add?as?many?recipients?as?we?like.
?8????????????oMsg.To.Add(new?System.Net.Mail.MailAddress("upzone@126.com",?"upzone"));
?9????????????//?Set?the?content
10????????????oMsg.Subject?=?"My?First?.NET?email";
11????????????oMsg.Body?=?"Test?body?-?.NET?Rocks!";
12????????????oMsg.IsBodyHtml?=?true;
13????????????System.Net.Mail.SmtpClient?oSmtp?=?new?System.Net.Mail.SmtpClient("smtp.126.com");
14????????????//You?can?choose?several?delivery?methods.?
15????????????//Here?we?will?use?direct?network?delivery.
16????????????oSmtp.DeliveryMethod?=?System.Net.Mail.SmtpDeliveryMethod.Network;
17????????????oSmtp.Timeout?=?5?*?60?*?1000;
18????????????//Some?SMTP?server?will?require?that?you?first?
19????????????//authenticate?against?the?server.
20????????????NetworkCredential?oCredential?=?new?NetworkCredential("upzone",?"123456");
21????????????oSmtp.UseDefaultCredentials?=?false;
22????????????oSmtp.Credentials?=?oCredential;
23????????????//Let's?send?it?already
24????????????oSmtp.Send(oMsg);
25
26????????}
發(fā)送不成功,沒(méi)有辦法,只好改回原來(lái)1.1的發(fā)送程序,等解決了2.0的問(wèn)題再說(shuō)了.

?1????????public?void?SendSmtpMail()
?2????????{
?3????????????System.Web.Mail.MailMessage?mail?=?new?System.Web.Mail.MailMessage();
?4????????????mail.To?=?"upzone@126.com";
?5????????????mail.From?=?"upzone@126.com";
?6????????????mail.Subject?=?"this?is?a?test?email.";
?7????????????mail.Body?=?"Some?text?goes?here";
?8????????????mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",?"1");?//basic?authentication?
?9????????????mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",?"upzone");?//set?your?username?here?
10????????????mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",?"123456");?//set?your?password?here?
11
12????????????System.Web.Mail.SmtpMail.SmtpServer?=?"smtp.126.com";?//your?real?server?goes?here?
13????????????System.Web.Mail.SmtpMail.Send(mail);?
14
15????????}

轉(zhuǎn)載于:https://www.cnblogs.com/upzone/archive/2006/04/25/384343.html

總結(jié)

以上是生活随笔為你收集整理的奇怪的问题,.Net 2.0发送邮件失败...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。