Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write General Mail Management in Jquery+Ajax+asp.net+sqlserver

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to write general mail management in Jquery+Ajax+asp.net+sqlserver". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to write general mail management in Jquery+Ajax+asp.net+sqlserver".

Preparation condition

This is my design table structure, and you can understand it at a glance.

-- Mail receipt form CREATE TABLE [dbo]. [TAB_MAILSENDRESERVED] ([FID] [nvarchar] (36) NULL, [MAILGUID] [nvarchar] (36) NULL, [SENDUSERID] [nvarchar] (36) NULL,-- sender [RESERVEDUSERID] [nvarchar] (36) NULL,-- receiver [SENDTIME] [datetime] NULL, [sorttime] [int] identity (1Jue 1) [ISBACKMSG] [int] DEFAULT ((0)), [STATUE] [int] DEFAULT ((0)), [ISDELETE] [int] DEFAULT ((0)), [SENDUSERNAME] [nvarchar] NULL, [RESERVEDNAME] [nvarchar] (200) NULL)-- email subject list CREATE TABLE [dbo]. [TAB_MAIL] ([ID] [nvarchar] (36) NULL [TITLE] [nvarchar] (300) NULL, [CONTENT] [text] NULL, [ISATTACHFILE] [int] default (0), [USINGCOUNT] [int] NULL)-- email attachment table 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)-- this is important (to determine how many users are currently using the attachment * only a person who deletes the email body data can physically delete the attachment) [FILENAMES] [nvarchar] (200) NULL)

Now all you need is an ID field or a UserID field in a user table.

Screenshot:

< persize) $("#btnmore").hide(); else $("#btnmore").show(); for (var i = 0; i < objresult.length; i++) { $("#datalist").append("" + objresult[i].RESERVEDNAME + "" + objresult[i].SENDTIME + "" + objresult[i].TITLE + "" + "已发送" + "" + (objresult[i].ISATTACHFILE == '1' ? "" : " ") + " 查看 转发 删除"); } }) } //收 function GetResBox() { $("#thlable009").html("发件人"); gettype = 0; $("#DivViewDT").hide(); $("#divmaillist").show(); if (pagesizeindex == "") $("#datalist").html(""); $("#WNewEmail").hide(); $("#divshow").show(); $("#hlistname").html("收件箱"); $.post("userajax/Mail.aspx", { "type": "getmysenddata", "userid": userid, "searchtype": "0", "pagesizeindex": pagesizeindex }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } if (data == null || data == "no" || data == "") { $("#datainfoa").html("无数据!"); $("#btnmore").hide(); return; } $("#datainfoa").html(""); var objresult = $.parseJSON(data); if (objresult == null) { $("#btnmore").hide(); return; } pagesizeindex = objresult[objresult.length - 1].sorttime; if (objresult.length < persize) $("#btnmore").hide(); else $("#btnmore").show(); for (var i = 0; i < objresult.length; i++) { $("#datalist").append("" + objresult[i].SENDUSERNAME + "" + objresult[i].SENDTIME + "" + objresult[i].TITLE + "" + (objresult[i].STATUE == "0" || objresult[i].STATUE == 0 ? "" : "") + "" + (objresult[i].STATUE == "0" || objresult[i].STATUE == 0 ? "新邮件" : "已读") + "" + (objresult[i].ISATTACHFILE == '1' ? "" : " ") + " 查看 转发 删除"); } }) } //回 function GetRebBox() { $("#thlable009").html("收件人"); gettype = 2; $("#DivViewDT").hide(); $("#divmaillist").show(); if (pagesizeindex == "") $("#datalist").html(""); $("#WNewEmail").hide(); $("#divshow").show(); $("#hlistname").html("回收站"); $.post("userajax/Mail.aspx", { "type": "getmysenddata", "userid": userid, "searchtype": "2", "pagesizeindex": pagesizeindex }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } if (data == null || data == "no" || data == "") { $("#datainfoa").html("无数据!"); $("#btnmore").hide(); return; } $("#datainfoa").html(""); var objresult = $.parseJSON(data); if (objresult == null) { $("#btnmore").hide(); return; } pagesizeindex = objresult[objresult.length - 1].sorttime; if (objresult.length < persize) $("#btnmore").hide(); else $("#btnmore").show(); for (var i = 0; i < objresult.length; i++) { $("#datalist").append("" + objresult[i].RESERVEDNAME + "" + objresult[i].SENDTIME + "" + objresult[i].TITLE + "已进回收站" + (objresult[i].ISATTACHFILE == '1' ? "" : " ") + " 还原 彻底删除"); } }) } load(); //页面加载 默认显示收件箱 function load() { GetResBox(); } //删除附件(多个) $("#spdelete").click(function () { if (confirm("确定删除吗?") == false) return; if (ismyupload == 0) { filename = []; filepath = []; filesize = []; $("#spdelete").hide(); $("#lablefile").html(""); return; } $.post("userajax/Mail.aspx", { "type": "deletefile", "pathlist": filepath.toString() }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } if (data == "1") $("#spdelete").hide(); $("#lablefile").html(""); }) }) /* // 文件上传 ------------------------- begin(华丽的分隔符) --------------------------- var button = $('#adlaimgFile'), interval; new AjaxUpload(button, { action: 'userajax/FileMail.ashx', name: 'imgFile', onSubmit: function (file, ext) { this.disable(); interval = window.setInterval(function () { var text = button.text(); }, 200); }, onComplete: function (file, response) { window.clearInterval(interval); this.enable(); response = response.replace(//ig, "").replace(//ig, ""); //过滤 var obj = $.parseJSON(response); if (obj[0].filetruename == "ferror") { alert("该文件类型不允许上传!"); return false; } if (obj[0].filetruename == "big") { alert("文件过大!"); return false; } filename.push(obj[0].filetruename); filepath.push(obj[0].filepath); filesize.push(obj[0].filesize); LoadJSFile(); } }); */ // _window.onload = load(); //默认加载收件箱数据 }) //dom end //标识是否为自己上传变量 var ismyupload = 1; //加载列表 function LoadJSFile() { $("#FilelistTbody").html(""); if (filename.length >

0) {$("# MailFileList2") .show ();} else {$("# MailFileList2") .hide (); return;} for (var I = 0; I

< filename.length; i++) $("#FilelistTbody").append("" + filename[i] + "" + filesize[i] + "k " + filename[i].substr(filename[i].lastIndexOf(".") + 1) + " "); } //删除单个附件 function deleteBypath(id, i) { if(confirm("确定删除吗?")==false)return; //不能删除邮件转发的附件 if (ismyupload == 0) { filename.pop(i); filepath.pop(i); filesize.pop(i); $("#trf" + i).remove(); if (filename.length < 1) $("#MailFileList2").hide(); else $("#MailFileList2").show(); return; } //物理删除 $.post("userajax/Mail.aspx", { "type": "deletefileone", "pathlist": id }, function (data) { if(data=="-999"){alert("登录失效.请重新登录!");return false;} if (data == "1") $("#trf" + i).remove(); filename.pop(i); filepath.pop(i); filesize.pop(i); if (filename.length < 1) $("#MailFileList2").hide(); else $("#MailFileList2").show(); }) } //function for button function maildo(type, id,num) { //收件箱删除 伪删除 if (type == "deleteinbox") { if (confirm("确定删除吗?") == false) return; $.post("userajax/Mail.aspx", { "type": "deleteinbox", "userid": userid, "idlist": id }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } $("#TRList" + num).remove(); MSG(); //pagesizeindex = ""; //GetResBox(); }); } //发件箱删除 伪删除 else if (type == "deleteoutbox") { if (confirm("确定删除吗?") == false) return; $.post("userajax/Mail.aspx", { "type": "deleteoutbox", "userid": userid, "idlist": id }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } $("#TRList" + num).remove(); MSG(); //pagesizeindex = ""; //GetSendBox(); }); } //回收站返回 else if (type == "backview") { $.post("userajax/Mail.aspx", { "type": "backview", "userid": userid, "idlist": id }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } $("#TRList" + num).remove(); MSG(); //pagesizeindex = ""; //GetRebBox(); }); } //回收站彻底删除 else if (type == "deleteon") { if (confirm("确定删除吗?") == false) return; $.post("userajax/Mail.aspx", { "type": "deleteon", "userid": userid, "idlist": id }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } $("#TRList" + num).remove(); MSG(); //pagesizeindex = ""; //GetRebBox(); }); } //查看邮件 else if (type == "view") { $("#DivViewDT").show(); $.post("userajax/Mail.aspx", { "type": "view", "userid": userid, "idlist": id }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } // if ($("#TRList" + id).html().toString().indexOf('新邮件') >

-1) / $("# TRList" + id). Html ($("# TRList" + id). Html (). Replace ("label label-important", "label"). Replace ("New Mail", "read"); $("# divmaillist"). Hide (); $("# DivViewDT"). Show () Var obj = $.parseJSON (data); $("# ViewTitle") .html ("email subject:" + obj [0] .title); $("# sendlable") .html ("sender:" + obj [0] .SENDUSERNAME); $("# reserveduname") .html ("recipient:" + obj [0] .RESERVEDAME) $("# sendtime") .html ("send time:" + obj [0] .SENDTIME); $("# contentlable") .html (decodeURIComponent (obj [0] .conent)); MSG ();}) / / attachment $("# Tbodyfilelistview"). Html ("); $.post (" userajax/Mail.aspx ", {" type ":" file "," id ": id}, function (data) {if (data ="-999 ") {alert (" login is invalid. Please log in again! "); return false;} if (data = = null | | data = =" no "| | data = =") {$(" # Afileresult "). Html (" No attachment! "); $(" # tablefilelist "). Hide (); return;} $(" # Afileresult ") .html ("); $(" # tablefilelist "). Show () Var obj = $.parseJSON (data); for (var I = 0; I

< obj.length; i++) { $("#Tbodyfilelistview").append("" + obj[i].FILENAME + "" + obj[i].FILESIZE + "k " + obj[i].FILETYPE + " "); } }) } //转发 else if (type == "forw") { $("#divmaillist").hide(); $("#WNewEmail").show(); $("#inputSendobj").val(""); ismyupload = 0; //控制不能删除别人附件 filename = []; filepath = []; filesize = []; //转发带附件的邮件 $.post("userajax/Mail.aspx", { "type": "file", "id": id }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } if (data == null || data == "no" || data == "") { $("#lablefile").html(""); return; } $("#lablefile").html(""); var obj = $.parseJSON(data); for (var i = 0; i < obj.length; i++) { filename.push(obj[i].FILENAME); filepath.push(obj[i].FILEPATH); filesize.push(obj[i].FILESIZE); } LoadJSFile(); }) $.post("userajax/Mail.aspx", { "type": "view", "userid": userid, "idlist": id }, function (data) { if (data == "-999") { alert("登录失效.请重新登录!"); return false; } // if ($("#TRList" + id).html().toString().indexOf('新邮件') >

-1) / / $("# TRList" + id). Html ($("# TRList" + id). Html (). Replace ("label label-important", "label"). Replace ("New Mail", "read"); var obj = $.parseJSON (data); $("# date01") .val (obj [0] .title) $("# textarea2") .val (decodeURIComponent (obj [0] .conent)); MSG () })} / / attachment else if (type = = "filedelete" | | type = = "file") {if (type = = "filedelete") {alert ("attachment cannot be viewed in the Recycle Bin!") ; return;} $("# DivFiles"). Modal ("show"); $("# FileListdata"). Html (""); $.post ("userajax/Mail.aspx", {"type": "file", "id": id}, function (data) {if (data = "- 999") {alert ("login is invalid. Please log in again! "); return false;} if (data = = null | | data = =" no "| | data = =") {$(" # fileinfoa "). Html (" No data! "); return;} $(" # fileinfoa "). Html ("); var obj = $.parseJSON (data); for (var I = 0) I < obj.length; iTunes +) {$("# FileListdata") .append ("" + obj [I] .FILENAME + "" + obj [I] .FILESIZE + "k" + obj [I] .FILETYPE + "") })})} / / download function downloadfile (fpath) {$.post ("Ajax/Floor.aspx", {"type": "existsfile", "filep": fpath}) Function (data) {if (data = = "noyes") {alert ("File does not exist!") Return;} else window.open ("Ajax/" + fpath); / / location.href = "Ajax/" + fpath;}) } / / message prompt box function MSG () {$("# divsysmsg") .show (); setInterval ("$('# divsysmsg') .hide ();", 2000);} / / get the name var scname= "scname" Function GetOrgName (name) {if (scname==name) {return;} scname=name; if (name== "'| | name==", "| | name=="! "| | name=='"') {$("# acount"). Html ("illegal character!"); return } / / filter character $("# divchecklist") .html (""); $("# imgprogress") .show (); $("# acount") .html ("") $.ajax ({url: "userajax/Mail.aspx", data: {"type": "getorgname", "searchval": name}, type: "POST", beforsend: function () {} Success: function (a) {setInterval ("$('# imgprogress') .hide () If (a = "- 1500") {alert ("login is invalid. Please log in again! "); return false;} if (a = =" no ") {$(" # acount ") .html (" 0 results "); return false;} / / No data var obj = $.parseJSON (a); $(" # acount ") .html (obj.length +" results ") / / get counts number for (var I = 0; I < obj.length; iTunes +) {if (exists (obj [I] .USERID) = = true) $("# divchecklist") .append ("

"+ obj [I] .MYUSERNAME +"

"); else $(" # divchecklist ") .append ("

"+ obj [I] .MYUSERNAME +"

");})} / / determine whether to select the data function exists (id) {for (var I = 0; I < ckidlist.length; iTunes +) {if (ckidlist [I] = = id) return true } return false;} / / send function GetSendBox () {$("# thlable009") .html ("recipient"); gettype = 1; $("# DivViewDT") .hide (); $("# divmaillist") .show () If (pagesizeindex = = ") $(" # datalist ") .html ("); $(" # WNewEmail ") .hide (); $(" # divshow ") .show (); $(" # hlistname ") .html (" Outbox ") Post ("userajax/Mail.aspx", {"type": "getmysenddata", "userid": userid, "searchtype": "1", "pagesizeindex": pagesizeindex}, function (data) {if (data = "- 999") {alert ("login is invalid. Please log in again! "); return false;} if (data = = null | | data = =" no "| | data = =") {$(" # datainfoa "). Html (" No data! "); $(" # btnmore "). Hide (); return;} $(" # datainfoa ") .html ("); var objresult = $.parseJSON (data) If (objresult = = null) {$("# btnmore") .hide (); return;} pagesizeindex = objresult [objresult.length-1] .sorttime; if (objresult.length < persize) $("# btnmore") .hide () Else $("# btnmore"). Show (); for (var I = 0; I < objresult.length) Append ("" + objresult [I] .RESERVEDNAME + "" + objresult.SENDTIME + "" + objresult.tile + "" + "sent" + "+ (objresult.ISATTACHFILE = ='1'?":") + "View forwarding deletion") })} / receive function GetResBox () {$("# thlable009") .html ("sender"); gettype = 0; $("# DivViewDT") .hide (); $("# divmaillist") .show () If (pagesizeindex = = ") $(" # datalist ") .html ("); $(" # WNewEmail ") .hide (); $(" # divshow ") .show (); $(" # hlistname ") .html (" Inbox ") Post ("userajax/Mail.aspx", {"type": "getmysenddata", "userid": userid, "searchtype": "0", "pagesizeindex": pagesizeindex}, function (data) {if (data = "- 999") {alert ("login is invalid. Please log in again! "); return false;} if (data = = null | | data = =" no "| | data = =") {$(" # datainfoa "). Html (" No data! "); $(" # btnmore "). Hide (); return;} $(" # datainfoa ") .html ("); var objresult = $.parseJSON (data) If (objresult = = null) {$("# btnmore") .hide (); return;} pagesizeindex = objresult [objresult.length-1] .sorttime; if (objresult.length < persize) $("# btnmore") .hide () Else $("# btnmore"). Show (); for (var I = 0; I < objresult.length) Append ("" + objresult.SENDUSERNAME + "" + objresult.SENDTIME + "" + objresult.TITLE + "+ (objresultI] .state =" 0 "| | objresult.STATUE = = 0?": ") +" + (objresult.state = "0" | | objresult[ I] .STATUE = "0" | | objresult.state = "0" | | objresult.state = 0? "New Mail": "read") + "+ (objresult.ISATACHFILE = ='1'?": ") +" View forward and delete ");}})} / return function GetRebBox () {$(" # thlable009 ") .ISATACHFILE (" recipient ") Gettype = 2; $("# DivViewDT"). Hide (); $("# divmaillist"). Show (); if (pagesizeindex = ") $(" # datalist "). Html ("); $("# WNewEmail"). Hide (); $("# divshow"). Show () $("# hlistname"). Html ("Recycle Bin"); $.post ("userajax/Mail.aspx", {"type": "getmysenddata", "userid": userid, "searchtype": "2", "pagesizeindex": pagesizeindex}, function (data) {if (data = "- 999") {alert ("login is invalid. Please log in again! "); return false;} if (data = = null | | data = =" no "| | data = =") {$(" # datainfoa "). Html (" No data! "); $(" # btnmore "). Hide (); return;} $(" # datainfoa ") .html ("); var objresult = $.parseJSON (data) If (objresult = = null) {$("# btnmore") .hide (); return;} pagesizeindex = objresult [objresult.length-1] .sorttime; if (objresult.length < persize) $("# btnmore") .hide () Else $("# btnmore"). Show (); for (var I = 0; I < objresult.length) IRecycle +) {$("# datalist") .append ("" + objresult.RESERVEDNAME + "" + objresult.SENDTIME + "+ objresult.tile +" entered the Recycle Bin "+ (objresult.ISATTACHFILE = ='1'?":") + "restore and delete completely";})})

Underlying implementation

(number of stripes to obtain data)

Object obj = Request.Form.Get ("type"); if (obj = = null | | obj.ToString () = = "") {Response.Write ("error"); Response.End () } / / Inbox Outbox Recycle Bin if (obj.ToString () = = "getmysenddata") Response.Write (getmysenddata (Common.GetUserCode (), int.Parse (Request.Form.Get ("searchtype")), Request.Form.Get ("pagesizeindex") / / Inbox delete else if (obj.ToString () = = "deleteinbox") Response.Write (deletevirtual (Common.GetUserCode (), Request.Form.Get ("idlist")) .ToString () / / delete else if (obj.ToString () = = "deleteoutbox") Response.Write (deletevirtual (Common.GetUserCode (), Request.Form.Get ("idlist"), 2) .ToString (); / / restore else if (obj.ToString () = = "backview") Response.Write (UpdateToBackBox (Request.Form.Get ("idlist")) .ToString ()) / / completely delete else if (obj.ToString () = = "deleteon") Response.Write (deleteon (Request.Form.Get ("idlist")) .ToString (); / / View else if (obj.ToString () = = "view") Response.Write (UpdateNumStatue (Request.Form.Get ("idlist") / / send a new email else if (obj.ToString () = = "addmsg") Response.Write (AddMsg () + ""); / / View the attachment else if (obj.ToString () = = "file") Response.Write (GetOneMailFiles (Request.Form.Get ("id") / / delete the attachment else if (obj.ToString () = = "deletefile") Response.Write (DeleteFileByMyself (Request.Form.Get ("pathlist")) .ToString (); / / delete the attachment else if (obj.ToString () = = "deletefileone") Response.Write (DeleteFileByMyself (Request.Form.Get ("pathlist"), 1). ToString ()) / / get organization name else if (obj.ToString () = = "getorgname") Response.Write (GetOrganizationName ()); / / query user message else if (obj.ToString () = = "getusernews") Response.Write (GetNewsByNotRead (Common.GetUserCode () Thank you for your reading, the above is the content of "how to write general mail management in Jquery+Ajax+asp.net+sqlserver". After the study of this article, I believe you have a deeper understanding of how to write general mail management in Jquery+Ajax+asp.net+sqlserver, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report