using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using hqgl.email;
using hqgl.user;
using System.Text.RegularExpressions;
using HtmlTextFormat;
using WebMessageBox;
public partial class general_email_new : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    //#region 下面的是用来草稿的
    //public void DataLoad(out string email_id,out emailinfo einfo)
    //{
    //    emailchuli eml = new emailchuli();
    //    einfo = new emailinfo();
    //    if (ViewState["EMAIL_ID"] != null)
    //        email_id = ViewState["EMAIL_ID"].ToString();
    //    else
    //        email_id = "";
    //    userchuli user = new userchuli();
    //    string to_id = Request["TO_ID"];
    //    string subject = Request["SUBJECT"];
    //    string FROM_ID = user.user_loginid();
    //    string COPY_TO_ID = Request["COPY_TO_ID"];
    //    string CONTENT = TextFormat.InString(Editor1.Text);
    //    string SEND_TIME = DateTime.Now.ToShortDateString();
    //    string READ_FLAG = Request["READ_FLAG"];
    //    string SEND_FLAG = Request["SEND_FLAG"];
    //    string DELETE_FLAG = Request["DELETE_FLAG"];
    //    string SMS_REMIND = Request["SMS_REMIND"];
    //    string IMPORTANT = Request.Form.Get("IMPORTANT");
    //    einfo.EMAIL_ID = email_id;
    //    einfo.TO_ID = to_id; 
    //    einfo.SUBJECT = subject;
    //    einfo.FROM_ID=FROM_ID;
    //    einfo.COPY_TO_ID=COPY_TO_ID;
    //    einfo.CONTENT=CONTENT;
    //    einfo .SEND_TIME=SEND_TIME;
    //    einfo.SEND_FLAG=SEND_FLAG;
    //    einfo.DELETE_FLAG=DELETE_FLAG;
    //    einfo.SMS_REMIND=SMS_REMIND;
    //    einfo.IMPORTANT=IMPORTANT;
        
    //}
    //protected void upload_at_Click(object sender, EventArgs e)
    //{
    //    string email_id;
    //    emailinfo einfo;
    //    emailchuli eml = new emailchuli();
    //    string err, dir="";
    //    int status;
    //    DataLoad(out email_id, out einfo);
    //    if (string.IsNullOrEmpty(einfo.TO_ID) & string.IsNullOrEmpty(einfo.SUBJECT))
    //        return;
    //    status = eml.Save_Attachment(ATTACHMENT.FileBytes, ATTACHMENT.FileName,email_id,out dir, out err);
    //    einfo.ATTACHMENT_ID = dir;
    //    if (string.IsNullOrEmpty(email_id))
    //        einfo.ATTACHMENT_NAME = ATTACHMENT.FileName;
    //    else
    //    {
    //        string flst = "";
    //        eml.Email_GetAt(email_id, out flst);
    //        string pattern = @"((?<=,)|(?<=\b))###?((?=,)|(?=$))";
    //        string name=ATTACHMENT.FileName.Replace(".","\\.");
    //        pattern = pattern.Replace("###", name);
    //        Regex rex = new Regex(pattern, RegexOptions.IgnoreCase);
    //        if (rex.IsMatch(flst))
    //            einfo.ATTACHMENT_NAME = flst;
    //        else
    //            einfo.ATTACHMENT_NAME = flst + "," + ATTACHMENT.FileName;
    //    }
    //    if (status == 1)
    //    {
    //        if (string.IsNullOrEmpty(email_id))
    //            eml.Email_Add(einfo/*,ut email_id*/);
    //        else
    //            eml.Email_Edit(einfo);
    //        ViewState["EMAIL_ID"] = email_id;
    //        GridView1.DataSource = eml.Email_GetAttachment(email_id);
    //        GridView1.DataBind();
    //        PlaceHolder1.UpdateAfterCallBack = true;
    //    }
    //    else
    //    {
    //        sta.Text = "上传失败";
    //        sta.UpdateAfterCallBack= true;
    //    }
    //}
    //#endregion
    protected void Submit1_ServerClick(object sender, EventArgs e)
    {
        emailinfo einfo = new emailinfo();
        einfo.TO_ID = Request["to_id"];
        einfo.SUBJECT = Text1.Value;
        einfo.CONTENT =TextFormat.InString(Editor1.Text);
        einfo.SEND_TIME = DateTime.Now.ToShortDateString() ;
        einfo.FROM_ID = Session["u_id"].ToString() ;
        einfo.READ_FLAG = "0";
        einfo.SEND_FLAG = "1";
        einfo.DELETE_FLAG = "0";
        emailchuli eml = new emailchuli();
        if (eml.Email_Add(einfo) == 1)
            MessageBox.Show("发送成功", "default.aspx");
        
    }
}
