《拓文asp.net网站内容管理系统》官方演示站。
 设为首页  
 收藏本站
 作者:黄振安
 QQ:53854651
首 页 开源拓文.NET编程网站编程网页设计图形图像数据库软件工程留言本
    站内搜索:  
您现在的位置: 拓文网络 → .NET编程 → ASP.NET → 一个通过web.Mail发送邮件的类[正文]

热 门 文 章

相 关 文 章
  • ASP.NET性能优化
  • 在.NET框架应用程序中发送电子邮件
  • .net打包自动安装数据库
  • asp.net开发wap必备:更好的匹配手机设备
  • 用ashx动态生成文件
  • windows 2003下asp.Net站点无法使用用户名+密码的方
  • ASP.NET中17种正则表达式
  • 提高ASP.Net应用程序性能的十大方法
  • 在DataGrid里面根据日期的不同显示new图标
  • Asp.Net细节性问题精萃
  • 一个通过web.Mail发送邮件的类
     
    [作者:不详    转贴自:不详    点击数:    更新时间:2006-3-2 15:28:39]

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


     }
    }


    首页 | 1 | 尾页  共 1 页
     
    winner 打印本页 关闭窗口

         文 章 评 论
    评论人 查看该文章的评论 发表时间
       笔 名* : 0 50分 60分 70分 80分 90分 100分
    评论内容 *: (最多1000字。当前字数:0)


    没有相关评论,欢迎您参与!

    - 关于本站 - 网站帮助 - 下载声明 - 友情连接 - 网站地图 -
    Copyright © 2005-2006 myTopWin.Com. All Rights Reserved . [桂ICP备06004496号]