using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using xabaraCOM;

public partial class inClude_js : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            sqlServer sql = new sqlServer();
            email mail = new email();
            ipAddress ip = new ipAddress();

            DataTable dt;
            string webName = xml.read("xabara.config", "webName", 180);
            string strDim = string.Empty;
            string[] strValue = new string[10];

            //检查邮件发送
            dt = sql.getDataTable("select top 1 * from mailSend where flagID=0 order by sendOrderBy ASC,mID ASC");
            if (dt.Rows.Count > 0)
            {
                bool isSend=mail.send(dt.Rows[0]["email"].ToString().Trim(), webName, dt.Rows[0]["mailTitle"].ToString().Trim(), dt.Rows[0]["mailContent"].ToString().Trim(), string.Empty);

                //及时更新已发送的邮箱
                strDim = "@flagID,@sendDate,@sendIP";
                if (isSend)
                {
                    strValue[0] = "1";
                }
                else
                {
                    //发送失败
                    strValue[1] = "2";
                }
                strValue[1] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                strValue[2] = ip.address();
                sql.update("mailSend", strDim, strValue, " mID=" + dt.Rows[0]["mID"].ToString().Trim());
            }
            dt.Dispose();
        }
    }
}