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

                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
发布了250 篇原创文章 · 获赞 1 · 访问量 39万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览