网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP.NET技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.在ASP.NET中把图片保存到SQL SER.
.记时器在ASP.NET中的应用.
.从 PHP 迁移到 ASP.NET.
.ASP.NET保持用户状态的九种选择(.
.ASP.NET2.0下含有CheckBox的Grid.
.使用PagedDataSource类实现DataL.
.ASP.NET 2.0下的条件编译.
.ASP.NET中利用cookies保持客户端.
.安装IE补丁后ASP.NET将无法运行.
..Net分页控件发布.
.从asp.net页面发送电子邮件 .
.如何实现用ODBC连接MySQL和ASP.N.
.ASP.NET2.0自动搜索文件组成导航.
.配置.net 3.0开发环境.
.JSP与ASP.Net之间的Session值共享.
.DataGridView 的分页处理.
.Asp.net中防止用户多次登录的方法.
.通过系统配置来提高ASP.NET应用程.
.用ASP/ASP.NET实现网络空间管理.
.在asp.net 页面中加入skype功能.

一个通过web.Mail发送邮件的类

发表日期:2005-9-29


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;
   }
  }

 
 }
}

上一篇:提高ASP.Net应用程序性能的十大方法 人气:9701
下一篇:在DataGrid里面根据日期的不同显示new图标 人气:10163
浏览全部web.Mail的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐