zoukankan      html  css  js  c++  java
  • Jquery+Ajax+asp.net+sqlserver-编写的通用邮件管理(有源码)

    开始

              邮件管理通常用在各个内部系统中,为了方便快捷的使用现有的代码开发一个邮件管理系统而诞生的、

    准备条件

    这是我的设计表结构,大家一看就懂了

    --邮件接收表
    CREATE
    TABLE [dbo].[TAB_MAILSENDRESERVED]( [FID] [nvarchar](36) NULL, [MAILGUID] [nvarchar](36) NULL, [SENDUSERID] [nvarchar](36) NULL,--发送人 [RESERVEDUSERID] [nvarchar](36) NULL,--接收人 [SENDTIME] [datetime] NULL, [sorttime] [int] identity(1,1) , [ISBACKMSG] [int] DEFAULT ((0)) , [STATUE] [int] DEFAULT ((0)), [ISDELETE] [int] DEFAULT ((0)), [SENDUSERNAME] [nvarchar](200) NULL, [RESERVEDNAME] [nvarchar](200) NULL )

    --邮件主题表
    CREATE
    TABLE [dbo].[TAB_MAIL]( [ID] [nvarchar](36) NULL, [TITLE] [nvarchar](300) NULL, [CONTENT] [text] NULL, [ISATTACHFILE] [int] default(0) , [USINGCOUNT] [int] NULL )


    
    
    
     
    --邮件附件表
    CREATE
    TABLE [dbo].[TAB_MAILFILES]( [FILEID] [nvarchar](36) NULL, [FILEPATH] [nvarchar](100) NULL, [FILETYPE] [nvarchar](10) NULL, [FILESIZE] [nvarchar](10) NULL, [USINGCOUNT] [int] default(0) ,--这个很重要(判断当前多少用户使用该附件,最后一个删除邮件主体数据的才能物理删除该附件) [FILENAMES] [nvarchar](200) NULL )
    
    
    
    
    

           现在只需要一个用户表中一个ID字段或者UserID字段。

    截图:

      地址在这里:http://10086bank.com/  里面的”邮件

    界面截图:(写新邮件,收件箱,发件箱,回收站之间可以拖动顺序) 界面打开默认获取收件箱数据。 如图:

    支持自己给自己发邮件,定时发送邮件。

    前端JS

      1         var userid = 1002; //test demo using value
      2         var filepath = []; //路径
      3         var filename = []; //名称
      4         var filesize = []; //大小
      5         var ckidlist = []; //判断是否存在
      6         var pagesizeindex = "", persize = 5;
      7         var gettype = 0; //0收件箱/1发件箱/2回收站
      8 
      9         $(function () {
     10             $("#WNewEmail").hide(); //新邮件框隐藏
     11             $("#divsysmsg").hide(); //提示框
     12             $("myModalA").hide(); //选择人list
     13             $("#DivViewDT").hide(); //邮件详情
     14 
     15             jQuery("#divall").validationEngine(); //验证
     16             jQuery("#divpeoplelistitle").validationEngine(); //验证
     17 
     18             //写新邮件
     19             $("#newemialdiv").click(function () {
     20                 $("#WNewEmail").show();
     21                 $("#divshow").hide(); //关闭列表
     22                 $("#DivViewDT").hide();
     23 
     24                 $("#inputSendobj").val(""); //选人id
     25                 $("#inputSendobjName").val(""); //选人name
     26                 $("#date01").val(""); //标题
     27                 $("#textarea2").val("")//内容
     28                 $("#lablefile").html(""); //显示附件名称
     29 
     30 
     31                 filename = [];
     32                 filepath = [];
     33                 filesize = [];
     34 
     35                 $("#FilelistTbody").html(""); //clear files
     36                 $("#MailFileList2").hide();
     37 
     38 
     39                 $("body[style='margin:4px; font:10pt Arial,Verdana; cursor:text']").html("<br _moz_editor_bogus_node='TRUE'></br>");
     40 
     41             });
     42             //取消写新邮件
     43             $("#btnclosedffsdfla").click(function () {
     44                 $("#WNewEmail").hide();
     45                 $("#divmaillist").show();
     46             });
     47             //关闭写新邮件
     48             $("#btncanceldiv").click(function () {
     49                 $("#WNewEmail").hide();
     50                 $("#divmaillist").show();
     51             });
     52             //关闭列表
     53             $("#close").click(function () {
     54                 $("#divshow").hide();
     55             });
     56             //modal show   选择发送人员
     57             $("#inputSendobjName").click(function () {
     58                 $("#myModalA").modal("show");
     59                 scname = "scname";
     60                 GetOrgName($("#searchpeopletxt").val());
     61             });
     62             //文本框查找机构
     63             $("#searchpeopletxt").keyup(function () {
     64                 GetOrgName($("#searchpeopletxt").val());
     65             });
     66             //关闭详细 显示列表
     67             $("#A4close").click(function () {
     68                 $("#DivViewDT").hide();
     69                 $("#divmaillist").show();
     70             });
     71             //check 选择人员提交
     72             $("#lasure").click(function () {
     73 
     74                 var inputSendobjName = "";
     75                 ckidlist = [];
     76 
     77                 $("#inputSendobj").val("");
     78                 var ob = $("input[name='checkboxA']");
     79                 $(ob).each(function () {
     80                     if ($(this).attr("checked") == "checked") {
     81                         $("#inputSendobj").val($("#inputSendobj").val() + $(this).attr("id") + ",");
     82 
     83                         ckidlist.push($(this).attr("id"));
     84 
     85                         inputSendobjName = inputSendobjName + $(this).attr("myname") + ",";
     86                     }
     87                 });
     88                 if ($("#inputSendobj").val() != "") {
     89                     $("#inputSendobj").val($("#inputSendobj").val().substr(0, $("#inputSendobj").val().length - 1));
     90                     inputSendobjName = inputSendobjName.substr(0, inputSendobjName.length - 1);
     91                 }
     92                 $("#inputSendobjName").val(inputSendobjName);
     93                 $("#Checkboxall").attr("checked", false);
     94             });
     95             //全选
     96             $("#Checkboxall").click(function () {
     97                 if ($("#Checkboxall").attr("checked") == "checked") {
     98                     var objall = $("input[name = 'checkboxA']");
     99                     $(objall).each(function () {
    100                         $(this).attr("checked", true);
    101                     })
    102                     return;
    103                 }
    104                 else {
    105                     var objall = $("input[name = 'checkboxA']");
    106                     $(objall).each(function () {
    107                         $(this).attr("checked", false);
    108                     })
    109                     return;
    110                 }
    111             });
    112             //反选
    113             $("#Checkboxback").click(function () {
    114                 if ($("#Checkboxback").attr("checked") == "checked") {
    115                     var objall = $("input[name = 'checkboxA']");
    116                     $(objall).each(function () {
    117                         if ($(this).attr("checked") == "checked")
    118                             $(this).attr("checked", false);
    119                     })
    120                     return;
    121                 }
    122                 else {
    123                     var objall = $("input[name = 'checkboxA']");
    124                     $(objall).each(function () {
    125                         if ($(this).attr("checked") == false)
    126                             $(this).attr("checked", true);
    127                     })
    128                     return;
    129                 }
    130             });
    131             //提交新邮件
    132             $("#btnsavedata").click(function () {
    133 
    134                 if (!jQuery('#divall').validationEngine('validate')) {
    135                     return;
    136                 }
    137 
    138                 if ($("#inputSendobj").val() == "") { alert("请选择收件人"); return false; }
    139 
    140                 var para = {
    141                     "topeople": $("#inputSendobj").val(),
    142                     "title": $("#date01").val(),
    143                     "content": encodeURIComponent($("#textarea2").val()),
    144                     "filepath": filepath.toString(),
    145                     "filename": filename.toString(),
    146                     "filesize": filesize.toString(),
    147                     "type": "addmsg",
    148                     "ttime": $("#txtsendtime").val() + " " + $("#txthour").val() + ":" + $("#txtmini").val() + ":00",
    149                     "userid": userid
    150                 };
    151 
    152                 $.post("userajax/Mail.aspx", para, function (data) {
    153                     $("#inputSendobj").val(""); //选人
    154                     $("#date01").val(""); //标题
    155                     $("#textarea2").val("")//内容
    156                     $("#lablefile").html(""); //显示附件名称
    157 
    158                     filename = [];
    159                     filepath = [];
    160                     filesize = [];
    161 
    162                     pagesizeindex = "";
    163                     GetSendBox();
    164                 })
    165 
    166             });
    167             $("#btnmore").click(function () {
    168                 if (gettype == 0)
    169                     GetResBox();
    170                 else if (gettype == 1)
    171                     GetSendBox();
    172                 else if (gettype == 2)
    173                     GetRebBox();
    174             })
    175 
    176             //
    177             $("#A1").click(function () {
    178                 pagesizeindex = "";
    179                 GetSendBox();
    180             });
    181             //
    182             $("#A2").click(function () {
    183                 pagesizeindex = "";
    184                 GetResBox();
    185             });
    186             //
    187             $("#A3").click(function () {
    188                 pagesizeindex = "";
    189                 GetRebBox();
    190             });
    191 
    192             //
    193             function GetSendBox() {
    194                 $("#thlable009").html("收件人");
    195                 gettype = 1;
    196                 $("#DivViewDT").hide();
    197                 $("#divmaillist").show();
    198 
    199                 if (pagesizeindex == "")
    200                     $("#datalist").html("");
    201 
    202                 $("#WNewEmail").hide();
    203                 $("#divshow").show();
    204                 $("#hlistname").html("<i class='icon-user'></i>发件箱");
    205 
    206                 $.post("userajax/Mail.aspx", { "type": "getmysenddata", "userid": userid, "searchtype": "1", "pagesizeindex": pagesizeindex }, function (data) {
    207                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    208                     if (data == null || data == "no" || data == "") { $("#datainfoa").html("无数据!"); $("#btnmore").hide(); return; }
    209                     $("#datainfoa").html("");
    210 
    211                     var objresult = $.parseJSON(data);
    212 
    213                     if (objresult == null) {
    214                         $("#btnmore").hide();
    215                         return;
    216                     }
    217 
    218                     pagesizeindex = objresult[objresult.length - 1].sorttime;
    219 
    220                     if (objresult.length < persize)
    221                         $("#btnmore").hide();
    222                     else
    223                         $("#btnmore").show();
    224 
    225 
    226                     for (var i = 0; i < objresult.length; i++) {
    227                         $("#datalist").append("<tr id='TRList" + objresult[i].sorttime + "'><td>" + objresult[i].RESERVEDNAME + "</td><td class='center'>" + objresult[i].SENDTIME + "</td><td class='center'>" + objresult[i].TITLE + "</td><td class='center'><span class='label label-important'>" + "已发送" + "</span></td><td>" + (objresult[i].ISATTACHFILE == '1' ? "<span class='icon32 icon-color icon-link' title='.icon32  .icon-color  .icon-link ' onclick=maildo('file','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')></span>" : " ") + "</td><td class='center'><table border='0'><tr border='0'><td><a class='btn btn-success'    onclick=maildo('view','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-zoom-in icon-white'></i> 查看</a></td><td><a class='btn btn-info'    onclick=maildo('forw','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-edit icon-white'></i> 转发</a></td><td><a class='btn btn-danger'    onclick=maildo('deleteoutbox','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-trash icon-white'></i>   删除</a></td></tr></table></td></tr>");
    228                     }
    229                 })
    230             }
    231 
    232             //
    233             function GetResBox() {
    234                 $("#thlable009").html("发件人");
    235                 gettype = 0;
    236                 $("#DivViewDT").hide();
    237                 $("#divmaillist").show();
    238 
    239 
    240                 if (pagesizeindex == "")
    241                     $("#datalist").html("");
    242 
    243                 $("#WNewEmail").hide();
    244                 $("#divshow").show();
    245                 $("#hlistname").html("<i class='icon-user'></i>收件箱");
    246 
    247                 $.post("userajax/Mail.aspx", { "type": "getmysenddata", "userid": userid, "searchtype": "0", "pagesizeindex": pagesizeindex }, function (data) {
    248                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    249                     if (data == null || data == "no" || data == "") { $("#datainfoa").html("无数据!"); $("#btnmore").hide(); return; }
    250                     $("#datainfoa").html("");
    251                     var objresult = $.parseJSON(data);
    252 
    253                     if (objresult == null) {
    254                         $("#btnmore").hide();
    255                         return;
    256                     }
    257 
    258                     pagesizeindex = objresult[objresult.length - 1].sorttime;
    259 
    260                     if (objresult.length < persize)
    261                         $("#btnmore").hide();
    262                     else
    263                         $("#btnmore").show();
    264 
    265                     for (var i = 0; i < objresult.length; i++) {
    266                         $("#datalist").append("<tr id='TRList" + objresult[i].sorttime + "'><td>" + objresult[i].SENDUSERNAME + "</td><td class='center'>" + objresult[i].SENDTIME + "</td><td class='center'>" + objresult[i].TITLE + "</td><td class='center'>" + (objresult[i].STATUE == "0" || objresult[i].STATUE == 0 ? "<span class='label label-important'>" : "<span class='label'>") + "" + (objresult[i].STATUE == "0" || objresult[i].STATUE == 0 ? "新邮件" : "已读") + "</span></td><td>" + (objresult[i].ISATTACHFILE == '1' ? "<span class='icon32 icon-color icon-link' title='.icon32  .icon-color  .icon-link ' onclick=maildo('file','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')></span>" : " ") + "</td><td class='center'><table border='0'><tr border='0'><td><a class='btn btn-success'    onclick=maildo('view','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-zoom-in icon-white'></i> 查看</a></td><td><a class='btn btn-info'    onclick=maildo('forw','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-edit icon-white'></i> 转发</a></td><td><a class='btn btn-danger'    onclick=maildo('deleteinbox','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-trash icon-white'></i>   删除</a></td></tr></table></td></tr>");
    267                     }
    268                 })
    269             }
    270 
    271             //
    272             function GetRebBox() {
    273                 $("#thlable009").html("收件人");
    274                 gettype = 2;
    275                 $("#DivViewDT").hide();
    276                 $("#divmaillist").show();
    277 
    278                 if (pagesizeindex == "")
    279                     $("#datalist").html("");
    280 
    281                 $("#WNewEmail").hide();
    282                 $("#divshow").show();
    283                 $("#hlistname").html("<i class='icon-user'></i>回收站");
    284 
    285                 $.post("userajax/Mail.aspx", { "type": "getmysenddata", "userid": userid, "searchtype": "2", "pagesizeindex": pagesizeindex }, function (data) {
    286 
    287                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    288 
    289                     if (data == null || data == "no" || data == "") { $("#datainfoa").html("无数据!"); $("#btnmore").hide(); return; }
    290 
    291                     $("#datainfoa").html("");
    292                     var objresult = $.parseJSON(data);
    293 
    294                     if (objresult == null) {
    295                         $("#btnmore").hide();
    296                         return;
    297                     }
    298 
    299                     pagesizeindex = objresult[objresult.length - 1].sorttime;
    300 
    301                     if (objresult.length < persize)
    302                         $("#btnmore").hide();
    303                     else
    304                         $("#btnmore").show();
    305 
    306                     for (var i = 0; i < objresult.length; i++) {
    307                         $("#datalist").append("<tr id='TRList" + objresult[i].sorttime + "'><td>" + objresult[i].RESERVEDNAME + "</td><td class='center'>" + objresult[i].SENDTIME + "</td><td class='center'>" + objresult[i].TITLE + "</td><td class='center'><span class='label'>已进回收站</span></td><td>" + (objresult[i].ISATTACHFILE == '1' ? "<span class='icon32 icon-color icon-link' title='.icon32  .icon-color  .icon-link ' onclick=maildo('filedelete','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')></span>" : " ") + "</td><td class='center'><table border='0'><tr border='0'><td><a class='btn btn-success'    onclick=maildo('backview','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-zoom-in icon-white'></i> 还原</a></td><td><a class='btn btn-danger'    onclick=maildo('deleteon','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-trash icon-white'></i>   彻底删除</a></td></tr></table></td></tr>");
    308                     }
    309                 })
    310             }
    311 
    312             load();
    313 
    314             //页面加载 默认显示收件箱
    315             function load() {
    316                 GetResBox();
    317             }
    318 
    319             //删除附件(多个)
    320             $("#spdelete").click(function () {
    321                 if (confirm("确定删除吗?") == false) return;
    322 
    323                 if (ismyupload == 0) { filename = []; filepath = []; filesize = []; $("#spdelete").hide(); $("#lablefile").html(""); return; }
    324                 $.post("userajax/Mail.aspx", { "type": "deletefile", "pathlist": filepath.toString() }, function (data) {
    325                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    326                     if (data == "1")
    327                         $("#spdelete").hide();
    328                     $("#lablefile").html("");
    329                 })
    330             })
    331 
    332             /*
    333             // 文件上传 ------------------------- begin(华丽的分隔符) ---------------------------
    334             var button = $('#adlaimgFile'), interval;
    335             new AjaxUpload(button, {
    336             action: 'userajax/FileMail.ashx',
    337             name: 'imgFile',
    338             onSubmit: function (file, ext) {
    339             this.disable();
    340             interval = window.setInterval(function () {
    341             var text = button.text();
    342             }, 200);
    343             },
    344             onComplete: function (file, response) {
    345             window.clearInterval(interval);
    346             this.enable();
    347             response = response.replace(/<pre>/ig, "").replace(/</pre>/ig, ""); //过滤
    348             var obj = $.parseJSON(response);
    349             if (obj[0].filetruename == "ferror") { alert("该文件类型不允许上传!"); return false; }
    350             if (obj[0].filetruename == "big") { alert("文件过大!"); return false; }
    351             filename.push(obj[0].filetruename);
    352             filepath.push(obj[0].filepath);
    353             filesize.push(obj[0].filesize);
    354 
    355             LoadJSFile();
    356             }
    357             });
    358             */
    359 
    360             // window.onload = load(); //默认加载收件箱数据
    361         })
    362         //dom end
    363 
    364         //标识是否为自己上传变量
    365         var ismyupload = 1;
    366 
    367         //加载列表
    368         function LoadJSFile() {
    369             $("#FilelistTbody").html("");
    370 
    371             if (filename.length > 0) {
    372                 $("#MailFileList2").show();
    373             }
    374             else {
    375                 $("#MailFileList2").hide();
    376                 return;
    377             }
    378             for (var i = 0; i < filename.length; i++)
    379                 $("#FilelistTbody").append("<tr id='trf" + i + "'><td>" + filename[i] + "</td><td class='center'>" + filesize[i] + "k </td><td class='center'>" + filename[i].substr(filename[i].lastIndexOf(".") + 1) + "</td><td class='center'><span class='icon icon-color icon-close'  onclick=deleteBypath('" + encodeURIComponent(filepath[i]) + "','" + i + "')> </span></td></tr>");
    380         }
    381 
    382 
    383         //删除单个附件
    384         function deleteBypath(id, i) {
    385            if(confirm("确定删除吗?")==false)return;
    386         
    387             //不能删除邮件转发的附件
    388             if (ismyupload == 0) {
    389                 filename.pop(i);
    390                 filepath.pop(i);
    391                 filesize.pop(i);
    392                 $("#trf" + i).remove();
    393                 if (filename.length < 1)
    394                     $("#MailFileList2").hide();
    395                 else
    396                     $("#MailFileList2").show();
    397                 return;
    398             }
    399             //物理删除
    400             $.post("userajax/Mail.aspx", { "type": "deletefileone", "pathlist": id }, function (data) {
    401                 if(data=="-999"){alert("登录失效.请重新登录!");return false;}
    402                 if (data == "1")
    403                     $("#trf" + i).remove();
    404                 filename.pop(i);
    405                 filepath.pop(i);
    406                 filesize.pop(i);
    407                 if (filename.length < 1)
    408                     $("#MailFileList2").hide();
    409                 else
    410                     $("#MailFileList2").show();
    411             })
    412         }
    413 
    414         //function for button
    415         function maildo(type, id,num) {
    416             //收件箱删除 伪删除
    417             if (type == "deleteinbox") {
    418                 if (confirm("确定删除吗?") == false) return;
    419                 $.post("userajax/Mail.aspx", { "type": "deleteinbox", "userid": userid, "idlist": id }, function (data) {
    420                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    421                     $("#TRList" + num).remove();
    422                     MSG();
    423                     //pagesizeindex = "";
    424                     //GetResBox();
    425                 });
    426             }
    427             //发件箱删除 伪删除
    428             else if (type == "deleteoutbox") {
    429                 if (confirm("确定删除吗?") == false) return;
    430                 $.post("userajax/Mail.aspx", { "type": "deleteoutbox", "userid": userid, "idlist": id }, function (data) {
    431                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    432                     $("#TRList" + num).remove();
    433                     MSG();
    434                     //pagesizeindex = "";
    435                     //GetSendBox();
    436                 });
    437             }
    438             //回收站返回
    439             else if (type == "backview") {
    440                 $.post("userajax/Mail.aspx", { "type": "backview", "userid": userid, "idlist": id }, function (data) {
    441                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    442                     $("#TRList" + num).remove();
    443                     MSG();
    444                     //pagesizeindex = "";
    445                     //GetRebBox();
    446                 });
    447             }
    448             //回收站彻底删除
    449             else if (type == "deleteon") {
    450                 if (confirm("确定删除吗?") == false) return;
    451                 $.post("userajax/Mail.aspx", { "type": "deleteon", "userid": userid, "idlist": id }, function (data) {
    452                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    453                     $("#TRList" + num).remove();
    454                     MSG();
    455                     //pagesizeindex = "";
    456                     //GetRebBox();
    457                 });
    458             }
    459             //查看邮件
    460             else if (type == "view") {
    461                 $("#DivViewDT").show();
    462                 $.post("userajax/Mail.aspx", { "type": "view", "userid": userid, "idlist": id }, function (data) {
    463                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    464 
    465                     // if ($("#TRList" + id).html().toString().indexOf('新邮件') > -1)
    466                     // $("#TRList" + id).html($("#TRList" + id).html().replace("label label-important", "label").replace("新邮件", "已读"));
    467 
    468                     $("#divmaillist").hide();
    469                     $("#DivViewDT").show();
    470 
    471                     var obj = $.parseJSON(data);
    472 
    473                     $("#ViewTitle").html("邮件主题:" + obj[0].TITLE);
    474                     $("#sendlable").html("发送人:" + obj[0].SENDUSERNAME);
    475                     $("#reserveduname").html("接收人:" + obj[0].RESERVEDNAME);
    476                     $("#sendtime").html("发送时间:" + obj[0].SENDTIME);
    477 
    478                     $("#contentlable").html(decodeURIComponent(obj[0].CONTENT));
    479                     MSG();
    480 
    481                 });
    482                 //附件
    483                 $("#Tbodyfilelistview").html("");
    484                 $.post("userajax/Mail.aspx", { "type": "file", "id": id }, function (data) {
    485                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    486                     if (data == null || data == "no" || data == "") { $("#Afileresult").html("无附件!"); $("#tablefilelist").hide(); return; }
    487                     $("#Afileresult").html("");
    488                     $("#tablefilelist").show();
    489                     var obj = $.parseJSON(data);
    490                     for (var i = 0; i < obj.length; i++) {
    491                         $("#Tbodyfilelistview").append("<tr><td><a target='_blank' href='Ajax/" + obj[i].FILEPATH + "'>" + obj[i].FILENAME + "</a></td><td class='center'>" + obj[i].FILESIZE + "k </td><td class='center'>" + obj[i].FILETYPE + "</td><td class='center'><span class='label label-success'> <i class='icon-download' onclick=downloadfile('" + obj[i].FILEPATH + "')></i>  </span></td></tr>");
    492                     }
    493                 })
    494             }
    495             //转发
    496             else if (type == "forw") {
    497                 $("#divmaillist").hide();
    498                 $("#WNewEmail").show();
    499 
    500                 $("#inputSendobj").val("");
    501                 ismyupload = 0; //控制不能删除别人附件
    502                 filename = []; filepath = []; filesize = [];
    503 
    504                 //转发带附件的邮件
    505                 $.post("userajax/Mail.aspx", { "type": "file", "id": id }, function (data) {
    506                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    507                     if (data == null || data == "no" || data == "") { $("#lablefile").html(""); return; }
    508                     $("#lablefile").html("");
    509                     var obj = $.parseJSON(data);
    510                     for (var i = 0; i < obj.length; i++) {
    511                         filename.push(obj[i].FILENAME);
    512                         filepath.push(obj[i].FILEPATH);
    513                         filesize.push(obj[i].FILESIZE);
    514                     }
    515                     LoadJSFile();
    516                 })
    517 
    518                 $.post("userajax/Mail.aspx", { "type": "view", "userid": userid, "idlist": id }, function (data) {
    519                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    520 
    521 
    522                     // if ($("#TRList" + id).html().toString().indexOf('新邮件') > -1)
    523                     // $("#TRList" + id).html($("#TRList" + id).html().replace("label label-important", "label").replace("新邮件", "已读"));
    524 
    525                     var obj = $.parseJSON(data);
    526 
    527                     $("#date01").val(obj[0].TITLE);
    528 
    529                     $("#textarea2").val(decodeURIComponent(obj[0].CONTENT));
    530 
    531                     MSG();
    532                 })
    533             }
    534             //附件
    535             else if (type == "filedelete" || type == "file") {
    536                 if (type == "filedelete") { alert("回收站中无法查看附件!"); return; }
    537                 $("#DivFiles").modal("show");
    538                 $("#FileListdata").html("");
    539                 $.post("userajax/Mail.aspx", { "type": "file", "id": id }, function (data) {
    540                     if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    541                     if (data == null || data == "no" || data == "") { $("#fileinfoa").html("无数据!"); return; }
    542                     $("#fileinfoa").html("");
    543                     var obj = $.parseJSON(data);
    544                     for (var i = 0; i < obj.length; i++) {
    545                         $("#FileListdata").append("<tr><td><a target='_blank' href='Ajax/" + obj[i].FILEPATH + "'>" + obj[i].FILENAME + "</a></td><td class='center'>" + obj[i].FILESIZE + "k </td><td class='center'>" + obj[i].FILETYPE + "</td><td class='center'><span class='label label-success'> <i class='icon-download' onclick=downloadfile('" + obj[i].FILEPATH + "')></i>  </span></td></tr>");
    546                     }
    547                 })
    548             }
    549         }
    550         
    551         //下载
    552         function downloadfile(fpath) {
    553             $.post("Ajax/Floor.aspx", { "type": "existsfile", "filep": fpath }, function (data) {
    554                 if (data == "noyes") {
    555                     alert("文件不存在!");
    556                     return;
    557                 }
    558                 else
    559                     window.open("Ajax/" + fpath);
    560                 //location.href = "Ajax/" + fpath;
    561             });
    562         }
    563 
    564         //消息提示框
    565         function MSG() {
    566             $("#divsysmsg").show();
    567             setInterval("$('#divsysmsg').hide();", 2000);
    568         }
    569         //获取名称
    570         var scname="scname";
    571         function GetOrgName(name) {
    572         
    573             if(scname==name){return;}
    574             scname=name;
    575             
    576             if (name == "'" || name == "," || name == "!" || name == '"') { $("#acount").html("非法字符!"); return; } //过滤字符
    577             $("#divchecklist").html("");
    578             $("#imgprogress").show();
    579             $("#acount").html("");
    580 
    581             $.ajax({
    582                 url: "userajax/Mail.aspx",
    583                 data: { "type": "getorgname", "searchval": name },
    584                 type: "POST",
    585                 beforsend: function () {
    586 
    587                 },
    588                 success: function (a) {
    589                     setInterval("$('#imgprogress').hide();", 1500);
    590                     if (a == "-999") { alert("登录失效.请重新登录!"); return false; }
    591                     if (a == "no") { $("#acount").html("0条结果"); return false; } //无数据
    592                     var obj = $.parseJSON(a);
    593                     $("#acount").html(obj.length + "条结果"); //get counts number
    594                     for (var i = 0; i < obj.length; i++) {
    595 
    596                         if (exists(obj[i].USERID) == true)
    597                             $("#divchecklist").append("<p><input  checked='checked'  type='checkbox' myname='" + obj[i].MYUSERNAME + "' name='checkboxA' id='" + obj[i].USERID + "' />" + obj[i].MYUSERNAME + "</p>");
    598                         else
    599                             $("#divchecklist").append("<p><input type='checkbox'  myname='" + obj[i].MYUSERNAME + "' name='checkboxA' id='" + obj[i].USERID + "' />" + obj[i].MYUSERNAME + "</p>");
    600                     }
    601                 }
    602             })
    603         }
    604         
    605         //判断是否选中该数据
    606         function exists(id) {
    607             for (var i = 0; i < ckidlist.length; i++) {
    608                 if (ckidlist[i] == id)
    609                     return true;
    610             }
    611             return false;
    612         }
    613 
    614         //
    615         function GetSendBox() {
    616             $("#thlable009").html("收件人");
    617             gettype = 1;
    618             $("#DivViewDT").hide();
    619             $("#divmaillist").show();
    620 
    621             if (pagesizeindex == "")
    622                 $("#datalist").html("");
    623 
    624             $("#WNewEmail").hide();
    625             $("#divshow").show();
    626             $("#hlistname").html("<i class='icon-user'></i>发件箱");
    627 
    628             $.post("userajax/Mail.aspx", { "type": "getmysenddata", "userid": userid, "searchtype": "1", "pagesizeindex": pagesizeindex }, function (data) {
    629                 if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    630                 if (data == null || data == "no" || data == "") { $("#datainfoa").html("无数据!"); $("#btnmore").hide(); return; }
    631                 $("#datainfoa").html("");
    632 
    633                 var objresult = $.parseJSON(data);
    634 
    635                 if (objresult == null) {
    636                     $("#btnmore").hide();
    637                     return;
    638                 }
    639 
    640                 pagesizeindex = objresult[objresult.length - 1].sorttime;
    641 
    642                 if (objresult.length < persize)
    643                     $("#btnmore").hide();
    644                 else
    645                     $("#btnmore").show();
    646 
    647 
    648                 for (var i = 0; i < objresult.length; i++) {
    649                     $("#datalist").append("<tr id='TRList" + objresult[i].sorttime + "'><td>" + objresult[i].RESERVEDNAME + "</td><td class='center'>" + objresult[i].SENDTIME + "</td><td class='center'>" + objresult[i].TITLE + "</td><td class='center'><span class='label label-important'>" + "已发送" + "</span></td><td>" + (objresult[i].ISATTACHFILE == '1' ? "<span class='icon32 icon-color icon-link' title='.icon32  .icon-color  .icon-link ' onclick=maildo('file','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')></span>" : " ") + "</td><td class='center'><table border='0'><tr border='0'><td><a class='btn btn-success'    onclick=maildo('view','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-zoom-in icon-white'></i> 查看</a></td><td><a class='btn btn-info'    onclick=maildo('forw','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-edit icon-white'></i> 转发</a></td><td><a class='btn btn-danger'    onclick=maildo('deleteoutbox','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-trash icon-white'></i>   删除</a></td></tr></table></td></tr>");
    650                 }
    651             })
    652         }
    653 
    654         //
    655         function GetResBox() {
    656             $("#thlable009").html("发件人");
    657             gettype = 0;
    658             $("#DivViewDT").hide();
    659             $("#divmaillist").show();
    660 
    661 
    662             if (pagesizeindex == "")
    663                 $("#datalist").html("");
    664 
    665             $("#WNewEmail").hide();
    666             $("#divshow").show();
    667             $("#hlistname").html("<i class='icon-user'></i>收件箱");
    668 
    669             $.post("userajax/Mail.aspx", { "type": "getmysenddata", "userid": userid, "searchtype": "0", "pagesizeindex": pagesizeindex }, function (data) {
    670                 if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    671                 if (data == null || data == "no" || data == "") { $("#datainfoa").html("无数据!"); $("#btnmore").hide(); return; }
    672                 $("#datainfoa").html("");
    673                 var objresult = $.parseJSON(data);
    674 
    675                 if (objresult == null) {
    676                     $("#btnmore").hide();
    677                     return;
    678                 }
    679 
    680                 pagesizeindex = objresult[objresult.length - 1].sorttime;
    681 
    682                 if (objresult.length < persize)
    683                     $("#btnmore").hide();
    684                 else
    685                     $("#btnmore").show();
    686 
    687                 for (var i = 0; i < objresult.length; i++) {
    688                     $("#datalist").append("<tr id='TRList" + objresult[i].sorttime + "'><td>" + objresult[i].SENDUSERNAME + "</td><td class='center'>" + objresult[i].SENDTIME + "</td><td class='center'>" + objresult[i].TITLE + "</td><td class='center'>" + (objresult[i].STATUE == "0" || objresult[i].STATUE == 0 ? "<span class='label label-important'>" : "<span class='label'>") + "" + (objresult[i].STATUE == "0" || objresult[i].STATUE == 0 ? "新邮件" : "已读") + "</span></td><td>" + (objresult[i].ISATTACHFILE == '1' ? "<span class='icon32 icon-color icon-link' title='.icon32  .icon-color  .icon-link ' onclick=maildo('file','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')></span>" : " ") + "</td><td class='center'><table border='0'><tr border='0'><td><a class='btn btn-success'    onclick=maildo('view','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-zoom-in icon-white'></i> 查看</a></td><td><a class='btn btn-info'    onclick=maildo('forw','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-edit icon-white'></i> 转发</a></td><td><a class='btn btn-danger'    onclick=maildo('deleteinbox','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-trash icon-white'></i>   删除</a></td></tr></table></td></tr>");
    689                 }
    690             })
    691         }
    692 
    693         //
    694         function GetRebBox() {
    695             $("#thlable009").html("收件人");
    696             gettype = 2;
    697             $("#DivViewDT").hide();
    698             $("#divmaillist").show();
    699 
    700 
    701             if (pagesizeindex == "")
    702                 $("#datalist").html("");
    703 
    704             $("#WNewEmail").hide();
    705             $("#divshow").show();
    706             $("#hlistname").html("<i class='icon-user'></i>回收站");
    707 
    708             $.post("userajax/Mail.aspx", { "type": "getmysenddata", "userid": userid, "searchtype": "2", "pagesizeindex": pagesizeindex }, function (data) {
    709 
    710                 if (data == "-999") { alert("登录失效.请重新登录!"); return false; }
    711 
    712                 if (data == null || data == "no" || data == "") { $("#datainfoa").html("无数据!"); $("#btnmore").hide(); return; }
    713 
    714                 $("#datainfoa").html("");
    715                 var objresult = $.parseJSON(data);
    716 
    717                 if (objresult == null) {
    718                     $("#btnmore").hide();
    719                     return;
    720                 }
    721 
    722                 pagesizeindex = objresult[objresult.length - 1].sorttime;
    723 
    724                 if (objresult.length < persize)
    725                     $("#btnmore").hide();
    726                 else
    727                     $("#btnmore").show();
    728 
    729                 for (var i = 0; i < objresult.length; i++) {
    730                     $("#datalist").append("<tr id='TRList" + objresult[i].sorttime + "'><td>" + objresult[i].RESERVEDNAME + "</td><td class='center'>" + objresult[i].SENDTIME + "</td><td class='center'>" + objresult[i].TITLE + "</td><td class='center'><span class='label'>已进回收站</span></td><td>" + (objresult[i].ISATTACHFILE == '1' ? "<span class='icon32 icon-color icon-link' title='.icon32  .icon-color  .icon-link ' onclick=maildo('filedelete','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')></span>" : " ") + "</td><td class='center'><table border='0'><tr border='0'><td><a class='btn btn-success'    onclick=maildo('backview','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-zoom-in icon-white'></i> 还原</a></td><td><a class='btn btn-danger'    onclick=maildo('deleteon','" + objresult[i].ID + "," + objresult[i].FID + "','" + objresult[i].sorttime + "')><i class='icon-trash icon-white'></i>   彻底删除</a></td></tr></table></td></tr>");
    731                 }
    732             })
    733         }
    View Code

    底层实现

         (分条数获取数据)

    object obj = Request.Form.Get("type");
    
            if (obj == null || obj.ToString() == "") { Response.Write("error"); Response.End(); }
    
            //收件箱 发件箱 回收站
            if (obj.ToString() == "getmysenddata")
                Response.Write(getmysenddata(Common.GetUserCode(), int.Parse(Request.Form.Get("searchtype")), Request.Form.Get("pagesizeindex")));
            //收件箱删除
            else if (obj.ToString() == "deleteinbox")
                Response.Write(deletevirtual(Common.GetUserCode(), Request.Form.Get("idlist")).ToString());
            //发件箱删除
            else if (obj.ToString() == "deleteoutbox")
                Response.Write(deletevirtual(Common.GetUserCode(), Request.Form.Get("idlist"), 2).ToString());
            //还原
            else if (obj.ToString() == "backview")
                Response.Write(UpdateToBackBox(Request.Form.Get("idlist")).ToString());
            //彻底删除
            else if (obj.ToString() == "deleteon")
                Response.Write(deleteon(Request.Form.Get("idlist")).ToString());
            //查看
            else if (obj.ToString() == "view")
                Response.Write(UpdateNumStatue(Request.Form.Get("idlist")));
            //发送新邮件
            else if (obj.ToString() == "addmsg")
                Response.Write(AddMsg() + "");
            //查看附件
            else if (obj.ToString() == "file")
                Response.Write(GetOneMailFiles(Request.Form.Get("id")));
            //删除自己上传的附件
            else if (obj.ToString() == "deletefile")
                Response.Write(DeleteFileByMyself(Request.Form.Get("pathlist")).ToString());
            //删除自己上传的附件
            else if (obj.ToString() == "deletefileone")
                Response.Write(DeleteFileByMyself(Request.Form.Get("pathlist"), 1).ToString());
            //获取机构名称
            else if (obj.ToString() == "getorgname")
                Response.Write(GetOrganizationName());
            //查询用户消息
            else if (obj.ToString() == "getusernews")
                Response.Write(GetNewsByNotRead(Common.GetUserCode()));

    最后

           需要源码的进入:http://10086bank.com/   点击邮件进入,然后点击写新邮件,给“feifei” 发送邮件 。

          人一辈子不会因为你做了什么而后悔,只会因为你没做什么而后悔。

          2014年,不平凡的一年。

    END

  • 相关阅读:
    BZOJ 2055 80人环游世界 有上下界最小费用可行流
    BZOJ 2406 LuoguP4194 矩阵 有上下界可行流
    BZOJ4873 LuoguP3749 寿司餐厅
    51nod 1551 集合交易 最大权闭合子图
    BZOJ 1565 植物大战僵尸 最大权闭合子图+网络流
    [CodeForces]460C Present
    [BZOJ5072] 小A的树
    [TJOI2015]组合数学
    [HNOI2006]鬼谷子的钱袋
    [IOI2007]矿工配餐
  • 原文地址:https://www.cnblogs.com/chinhi/p/common_mail_system_feifei.html
Copyright © 2011-2022 走看看