国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

解讀郵件發送CDO.Message錯誤

2024-07-21 02:25:31
字體:
來源:轉載
供稿:網友
喜歡上c#,再也沒有理由離開它去學另一種語言,asp中可以方便的調用cdo并附上賬

號和密碼來發送郵件,但system.web.mail命名空間里卻并未讓我等到輸入用戶名和密

碼的屬性,沒有驗證就會出現:cdo.message調用失敗。在觀看了別的同仁的文章,試了一個果然見效,在此與大家分享一下。
由于在.net平臺上并不在于程序寫多少,更不在于用什么語言去表達,重要的似乎是思

想,所以我喜歡c#也只用c#寫這幾句代碼吧,vb.net與j#的朋友可以稍微改一下即

可用了......
private static int gotosendmail(string body,string to)
{
try
{
system.web.mail.mailmessage mm=new system.web.mail.mailmessage();
mm.bodyformat=system.web.mail.mailformat.html;
mm.from="[email protected]";
mm.to=to;
mm.bodyencoding=system.text.encoding.getencoding(936);
mm.subject="您好!我是夢貓.net工作室希望與您攜手一起成長。";
mm.body=body;
mm.fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] =

2;
mm.fields

["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"] =

"[email protected]";//發送地址;如果mm.from寫了這兒可以不寫這句
mm.fields

["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"] =

"[email protected]";
mm.fields["http://schemas.microsoft.com/cdo/configuration/sendusername"]

= "xxx";//驗證賬號:發送者郵箱賬號
mm.fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"]

= "xxxpass"; //驗證密碼:發送者郵箱密碼
mm.fields

["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1; //

驗證級別0,1,2
mm.fields["http://schemas.microsoft.com/cdo/configuration/languagecode"]

= 0x0804;//語言代碼
mm.fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] =

"smtp.xxx.com"; //smtp server
system.web.mail.smtpmail.smtpserver="smtp.xxx.com";//上句和這句重著,這

句可以替代上句
system.web.mail.smtpmail.send(mm);
return 0;
}
catch(system.exception e)
{
response.write(e.message+e.stacktrace+e.source);
return -1;
}
}
本程序在xp和2000server iis6上均通過
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 五原县| 高陵县| 应城市| 蓬莱市| 荔波县| 蕉岭县| 黎城县| 青冈县| 茂名市| 屯门区| 泰宁县| 三亚市| 丹凤县| 龙山县| 吉安市| 全州县| 茶陵县| 海门市| 秦皇岛市| 桑日县| 长岛县| 西藏| 射洪县| 花莲县| 赣州市| 石河子市| 延吉市| 章丘市| 鹰潭市| 沂水县| 恩施市| 重庆市| 邛崃市| 富裕县| 锦屏县| 屯昌县| 象山县| 兴化市| 许昌县| 德庆县| 南充市|