国产探花免费观看_亚洲丰满少妇自慰呻吟_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;
                }
            }
        }
    }
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 伊宁市| 甘孜县| 始兴县| 明星| 卫辉市| 建水县| 靖西县| 平和县| 麦盖提县| 盱眙县| 贵阳市| 特克斯县| 上饶县| 寻乌县| 黄山市| 蛟河市| 靖江市| 崇明县| 巴林右旗| 庐江县| 股票| 陇西县| 垦利县| 鄯善县| 吐鲁番市| 西昌市| 庆安县| 桂平市| 江华| 邵武市| 绥德县| 大方县| 嘉鱼县| 西丰县| 彰化县| 信宜市| 福贡县| 无锡市| 东乌珠穆沁旗| 潮安县| 金堂县|