当前位置:编程学习 > C#/ASP.NET >>

使用System.Web.Mail通过需验证的邮件服务器发送邮件

使用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;
补充:asp.net教程,E-mail专题 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,