欢迎光临
我们一直在努力

使用System.Web.Mail通过需验证的邮件服务器发送邮件-.NET教程,E-mail专题

建站超值云服务器,限时71元/月

使用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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 使用System.Web.Mail通过需验证的邮件服务器发送邮件-.NET教程,E-mail专题
分享到: 更多 (0)

相关推荐

  • 暂无文章