下面是几段C#发送邮件相关的代码,我也懒得说明了,就这么个意思。

来源:互联网 发布:淘宝开店怎么样 编辑:程序博客网 时间:2024/04/27 23:30
                mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
                mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "joe.zhou");
                mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "zhou");

                    //for SMTP Authentication
                    if (Globals.GetSiteSettings(context).SmtpServerRequiredLogin) {
                        m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1" ); //basic authentication

                        m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", Globals.GetSiteSettings(context).SmtpServerUserName ); //set your username here

                        m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", Globals.GetSiteSettings(context).SmtpServerPassword ); //set your password here
                        // by venjiang 2004/12/31
                        // 超时时间增加
                        m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60);
                    }



        #region 应用程序初始化
        /// <summary>
        /// 应用程序初始化
        /// </summary>
        /// <param name="application"></param>
        public void Init(HttpApplication application)
        {

            // Wire-up application events
            //
            application.ResolveRequestCache += new EventHandler(this.BlockedIpAddress);

            application.BeginRequest += new EventHandler(this.Application_BeginRequest);
            application.AuthenticateRequest += new EventHandler(Application_AuthenticateRequest);
            application.Error += new EventHandler(this.Application_OnError);
            application.AuthorizeRequest += new EventHandler(this.Application_AuthorizeRequest);

#if DEBUG
            application.ReleaseRequestState += new EventHandler(this.Application_ReleaseRequestState);
#endif
           
            ForumConfiguration forumConfig = ForumConfiguration.GetConfig();
            if( forumConfig != null
            &&  forumConfig.IsBackgroundThreadingDisabled == false ) {
                if (emailTimer == null)
                    emailTimer = new Timer(new TimerCallback(ScheduledWorkCallbackEmailInterval), application.Context, EmailInterval, EmailInterval);

                if( forumConfig.IsIndexingDisabled == false
                &&    statsTimer == null ) {
                    statsTimer = new Timer(new TimerCallback(ScheduledWorkCallbackStatsInterval), application.Context, StatsInterval, StatsInterval);
                }
            }
           
        }
        #endregion