国产探花免费观看_亚洲丰满少妇自慰呻吟_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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南乐县| 岗巴县| 长乐市| 界首市| 临泽县| 娄底市| 惠水县| 正宁县| 东城区| 沙洋县| 民乐县| 锦屏县| 宁南县| 大田县| 田阳县| 调兵山市| 昌平区| 忻城县| 黔东| 休宁县| 桐城市| 安福县| 大悟县| 屏南县| 全州县| 高州市| 南城县| 台湾省| 柳州市| 新蔡县| 开化县| 吴旗县| 象州县| 高尔夫| 拉萨市| 和田县| 襄垣县| 边坝县| 岳西县| 镇康县| 团风县|