文章分类 | 软件分类 | 最新软件 | 杀毒软件 | 实用软件  | MTV下载  | 设为首页 |
  | 下载分类 | 最近更新
您的位置: 首页 >> 文章首页 >> 技术开发 >> .Net 专栏 >> ASP.NET技巧 >>  
ASP.NET技巧点击TOP10
·ASP.NET 2.0中使用自定义provider2006-2-10 12:49:07
·灵活正确的实现.NET插件机制2006-2-10 12:42:54
·asp.net如何生成图片验证码(简单)2006-2-10 12:24:18
·如何保证web app中的Send Email线程稳定性2006-2-10 12:00:59
·.NET环境下几种不同的邮件发送解决方案2006-2-10 12:00:59
·如何获取当前程序文件的路径 Current Path2006-2-10 12:46:13
·在Asp.net中为图像加入版权信息2006-2-10 12:42:56
·关于用ASP.Net识别远程主机服务器种类2006-2-10 12:02:36
·web中,如何读取Word内容(包含表格,但不包含图片)并且显示在页面中或保存进数据库中2006-2-10 12:00:57
·asp.net开发wap程序必备:识别来访手机品牌型号2006-2-10 12:46:17
.Net 专栏点击TOP10
·ADO.net中数据库连接方式2006-2-9 17:35:03
·ASP.NET里的事务处理2006-2-5 12:41:30
·使用Web服务将C#代码转换为VB.NET代码2006-2-9 18:10:39
·十天学会ASP.net之第九天2006-2-6 10:10:06
·如何给DataGrid添加双题头分类显示2006-2-5 18:46:43
·使用嵌套的Repeater控件2006-2-5 12:41:52
·Net 下安装、调试的常见问题与错误2006-2-9 9:04:53
·在ASP.NET中值得注意的两个地方2006-2-9 16:40:07
·C#中的非安全编程2006-2-9 17:32:38
·ASP.NET中利用cookies保持客户端信息2006-2-9 17:33:25

 

一个通过web.Mail发送邮件的类
作者:我去下载           时间:2006-2-10 12:54:03


using System;
using System.Web;
using System.Web.Mail;
using Dottext.Framework;
using Dottext.Framework.Configuration;

namespace YourNamespace.Email
{
 /// <summary>
 /// Default implementation of the IMailProvider
 /// </summary>
 public class SystemMail : IMailProvider
 {
  public SystemMail(){}

  #region
  private string _to;
  public string To
  {
   get{return _to;}
   set{_to = value;}
  }

  private string _from;
  public string From
  {
   get{return _from;}
   set{_from = value;}
  }

  private string _subject;
  public string Subject
  {
   get{return _subject;}
   set{_subject = value;}
  }

  private string _body;
  public string Body
  {
   get{return _body;}
   set{_body = value;}
  }
  #endregion

  private string _adminEmail;
  public string AdminEmail
  {
   get{return _adminEmail;}
   set{_adminEmail = value;}
  }

  private string _smtpServer = "localhost";
  public string SmtpServer
  {
   get{return _smtpServer;}
   set{_smtpServer = value;}
  }

  private string _password;
  public string Password
  {
   get{return _password;}
   set{_password = value;}
  }

  private string _userName;
  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;
   }
  }

 
 }
}

分页:
相关文章:
Copyright© 2005-2006 wqxz.com, All Rights Reserved. 购买虚拟主机请与本站联系