国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

郵件發送測試。Codebehind

2024-07-21 02:24:38
字體:
來源:轉載
供稿:網友
using system;
using system.web;
using system.web.ui;
using system.web.ui.webcontrols;
using blood.com.classlib;

namespace test
{
    /// <summary>
    /// 郵件發送例子
    /// </summary>
    public class sendmailsample : system.web.ui.page
    {
        protected system.web.ui.webcontrols.datagrid datagrid1;
        protected system.web.ui.webcontrols.dropdownlist ddlpriority;
        protected system.web.ui.webcontrols.dropdownlist ddlhtml;
        protected system.web.ui.webcontrols.textbox txtsmtphost;
        protected system.web.ui.webcontrols.textbox txtport;
        protected system.web.ui.webcontrols.textbox txtfrom;
        protected system.web.ui.webcontrols.textbox txtfromname;
        protected system.web.ui.webcontrols.textbox txtto;
        protected system.web.ui.webcontrols.textbox txttoname;
        protected system.web.ui.webcontrols.textbox txtsubject;
        protected system.web.ui.webcontrols.textbox txtmessage;
        protected system.web.ui.webcontrols.regularexpressionvalidator revport;
        protected system.web.ui.webcontrols.requiredfieldvalidator rfvsmtphost;
        protected system.web.ui.webcontrols.requiredfieldvalidator rfvport;
        protected system.web.ui.webcontrols.requiredfieldvalidator rfvfrom;
        protected system.web.ui.webcontrols.requiredfieldvalidator rfvto;
        protected system.web.ui.webcontrols.requiredfieldvalidator rfvsubject;
        protected system.web.ui.webcontrols.requiredfieldvalidator rfvmessage;
        protected system.web.ui.webcontrols.button btnsendmail;
        protected system.web.ui.webcontrols.label lblmessage;
        protected system.web.ui.webcontrols.regularexpressionvalidator revfrom;
        protected system.web.ui.webcontrols.regularexpressionvalidator revto;
        protected system.web.ui.webcontrols.panel pelmessage;
    
        private void page_load(object sender, system.eventargs e)
        {
        }

        #region web form designer generated code
        override protected void oninit(eventargs e)
        {
            //
            // codegen: this call is required by the asp.net web form designer.
            //
            initializecomponent();
            base.oninit(e);
        }
        
        /// <summary>
        /// required method for designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void initializecomponent()
        {    
            this.btnsendmail.click += new system.eventhandler(this.btnsendmail_click);
            this.load += new system.eventhandler(this.page_load);

        }
        #endregion

        private void btnsendmail_click(object sender, system.eventargs e)
        {
            if(ispostback)
            {
                smtpmail clsmail = new smtpmail();
                string strsmtphost = txtsmtphost.text;
                int intport = int32.parse(txtport.text);
                string strfrom = txtfrom.text;
                string strfromname = txtfromname.text;
                string strto = txtto.text;
                string strtoname = txttoname.text;
                smtpmail.prioritys priority = smtpmail.prioritys.normal;
                bool bolhtml;
                string strsubject = txtsubject.text;
                string strmessage = txtmessage.text;
                if(ddlpriority.selecteditem.text == "默認")
                {
                    priority = smtpmail.prioritys.normal;
                }
                else if(ddlpriority.selecteditem.text == "高")
                {
                    priority = smtpmail.prioritys.high;
                }
                else if(ddlpriority.selecteditem.text == "低")
                {
                    priority = smtpmail.prioritys.low;
                }
                if(ddlhtml.selecteditem.text == "是")
                {
                    bolhtml = true;
                }
                else
                {
                    bolhtml = false;
                }
                clsmail.sendmail(strsmtphost,intport,strfrom,strfromname,strto,strtoname,priority,bolhtml,"",strsubject,strmessage);
                if(clsmail.errormessage !="")
                {
                    pelmessage.visible = true;
                    lblmessage.text = clsmail.errormessage;
                    lblmessage.forecolor = system.drawing.color.red;
                }
                else
                {
                    pelmessage.visible = true;
                    lblmessage.text = "郵件發送成功";
                    lblmessage.forecolor = system.drawing.color.blue;
                }
            }
        }
    }
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 财经| 平和县| 浦北县| 云龙县| 兴海县| 丹棱县| 包头市| 义乌市| 赣州市| 巴南区| 深州市| 乳源| 四川省| 龙胜| 无棣县| 盐城市| 达尔| 应城市| 牡丹江市| 阿克陶县| 丹棱县| 万盛区| 美姑县| 石泉县| 寿宁县| 罗平县| 小金县| 南开区| 东港市| 淮安市| 武隆县| 陆河县| 星子县| 海晏县| 个旧市| 大安市| 安达市| 冷水江市| 元江| 辽阳市| 六枝特区|