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

首頁 > 開發 > 綜合 > 正文

使用System.Web.Mail通過需驗證的郵件服務器發送郵件

2024-07-21 02:24:36
字體:
來源:轉載
供稿:網友
使用system.web.mail通過需驗證的郵件服務器發送郵件



使用system.web.mail通過需驗證的郵件服務器發送郵件,下面是scott water在dottext中寫的一個發郵件的類,使用起來比較方便,整個類的代碼如下:

using system;

using system.web.mail;



namespace zz

{

///

/// systemmail 的摘要說明。

///

public class systemmail

{

private string _adminemail;

private string _smtpserver = "localhost";

private string _password;

private string _username;



public systemmail()

{

}





public string adminemail

{

get{return _adminemail;}

set{_adminemail = value;}

}





public string smtpserver

{

get{return _smtpserver;}

set{_smtpserver = value;}

}





public string password

{

get{return _password;}

set{_password = value;}

}





public string username

{

get{return _username;}

set{_username = value;}

}



public bool send(string to, string from, string subject, string message)

{

try

{

mailmessage em = new mailmessage();

em.to = to;

em.from = from;

em.subject = subject;

em.body = message;



//found out how to send authenticated email via system.web.mail at http://systemwebmail.com (fact 3.8)

if(this.username != null && this.password != null)

{

em.fields.add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication

em.fields.add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.username); //set your username here

em.fields.add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.password); //set your password here

}



smtpmail.smtpserver = this.smtpserver;

smtpmail.send(em);

return true;

}

catch

{

return false;

}

}



}

}

需要更多信息可以查看http://systemwebmail.com


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灵武市| 达州市| 买车| 都匀市| 电白县| 张北县| 刚察县| 朝阳县| 大化| 丹凤县| 贵阳市| 株洲市| 寻乌县| 晋江市| 图们市| 松滋市| 东宁县| 湘乡市| 潮安县| 银川市| 曲沃县| 延吉市| 永州市| 军事| 互助| 涞源县| 通渭县| 华宁县| 福海县| 喀什市| 济阳县| 屏东县| 绥阳县| 大丰市| 湟源县| 应用必备| 南岸区| 台东县| 高雄市| 富顺县| 巴塘县|