write.jsp
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:12k
源码类别:

WEB邮件程序

开发平台:

Java

  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  6. <title>发送邮件</title>
  7. <style type="text/css">
  8. <!--
  9. .Max {
  10.  width: 100%;
  11. }
  12. -->
  13. </style>
  14. <script language="JavaScript" src="include/CheckDataFunction.js" type="text/JavaScript"></script>
  15. <script language="javascript">
  16.   <!--
  17.  
  18.  function doSendAndSave()
  19.       {
  20.         if(setSend())
  21. {
  22. EditForm.action="writeMail.do?method=sendsave";
  23. setFiles();
  24.          EditForm.submit();
  25. }
  26. else
  27. return false;       
  28.       }//sendsave 
  29.       function doSend()
  30.       {
  31.         if(setSend())
  32. {
  33. EditForm.action="writeMail.do?method=send";
  34. setFiles();
  35.          EditForm.submit();
  36. }
  37. else
  38. return false;       
  39.       }//sendsave
  40.       function doSave()
  41.       {
  42.         if(setSend())
  43. {
  44. EditForm.action="writeMail.do?method=save";
  45.          EditForm.submit();
  46. }
  47. else
  48. return false;       
  49.       }//sendsave
  50.      
  51.       function choiceAddress(Obj)
  52.       {
  53.         var str='';
  54.         urls="address.ejf?easyJWebCommand=choice";
  55.         str=window.showModalDialog(urls,"addAccessory","dialogWidth:500px;dialogHeight:400px;help:no;status:no");
  56.         choice(Obj,str)
  57.    
  58.       }
  59.       function choice(Obj,str)
  60.       {
  61.         var allValue=Obj.value;
  62. if(str!=null)
  63. {
  64. if(allValue!=null && allValue!="")
  65. {
  66. allValue = allValue+",";
  67. }
  68. var tmpValue='';
  69. var Value=str.split('<>');
  70. for(var x=0;x<Value.length;x++)
  71. {
  72.   if(Value[x]!='')
  73.   {
  74. tmpValue=Value[x].split('|')
  75. if(allValue.indexOf(tmpValue[0])==-1)
  76. allValue+= tmpValue[0]+",";
  77.   }
  78. }
  79. }
  80. Obj.value = allValue.substring(0,allValue.length-1);
  81.       }
  82.       function DelCID(Obj)
  83.       {
  84.         for(var x=Obj.length-1;x>=0;x--)
  85.         {
  86.           if(Obj.options[x].selected)
  87.           {
  88.           Obj.options[x]=null;
  89.           }
  90.         }
  91.       }
  92. function changeEdit(obj)
  93. {
  94. if(EditForm.editMode.value == 'html')
  95. {
  96. if(!window.confirm('警告:如果将该邮件格式改为纯文本,可能会造成格式信息丢失!'))
  97. return false;
  98. EditForm.editMode.value = '1';
  99. EditForm.text.value = htmlRichedit.getPureText();
  100. EditForm.richedit.value= htmlRichedit.getPureText();
  101. htmlView.style.display="none";
  102. textView.style.display="";
  103. }
  104. else
  105. {
  106. EditForm.editMode.value = 'html';
  107. htmlRichedit.setHTML('<div><pre>'+EditForm.richedit.value+'</pre></div>');
  108. htmlView.style.display="";
  109. textView.style.display="none";
  110. }
  111. if(obj.innerText=="可视化编辑器")obj.innerText="文本编辑模式";
  112. else obj.innerText="可视化编辑器";
  113. return false;
  114. }
  115. function setSend()
  116. {
  117.         var x,n
  118.         var accessoryValue='<>';
  119.    if(Trim(EditForm.toUser.value)=="")
  120.         {
  121.           alert('请输入收件人');
  122.           EditForm.toUser.focus();
  123.           return false;
  124.         }
  125.         if(EditForm.copyTo.length>=1000)
  126.         {
  127.           alert('邮件最多只能抄送10位接收者!n如要发送给多个人员,请选择多个收件人!');
  128.           EditForm.copyTo.focus();
  129.           return false;
  130.         }
  131.         if(Trim(EditForm.subject.value)=='')
  132.         {
  133.           alert('请输入主题!');
  134.           EditForm.Subject.focus();
  135.           return false;
  136.         }      
  137.        // EditForm.accessory.value =accessoryValue;
  138. if(EditForm.editMode.value=="html")
  139. EditForm.text.value = '<html>'+htmlRichedit.getHTML()+'</html>';
  140. else
  141. EditForm.text.value = EditForm.richedit.value;
  142. // alert(EditForm.text.value);
  143. return true;
  144. }
  145. var fileCount=1;
  146. function addRow(objTable){
  147.  var newfirstRow=" <tr><td width="60">附 件 : </td><td><input type="file" name="file0"></td></tr>";
  148.  var tbodyOnlineEdit=objTable.getElementsByTagName("TBODY")[0];
  149.  alert(tbodyOnlineEdit.innerHTML);
  150.  //里面一个附件都没有
  151.  if(tbodyOnlineEdit.innerHTML==""){
  152.        tbodyOnlineEdit.innerHTML=newfirstRow;
  153.     //tbodyOnlineEdit.insertBefore(elm);
  154.  }else{
  155.  var elm = tbodyOnlineEdit.children[0].cloneNode(true);
  156.  
  157.  elm.id="dataRow"+fileCount++;//设置行的ID 
  158.  //设置表单name 
  159.  elm.children[1].children[0].name="file"+fileCount;
  160.  
  161. // elm.children[2].children[0].name="amountT"+countId;
  162. //插入表单
  163.  tbodyOnlineEdit.insertBefore(elm);
  164.  }
  165. }
  166. //删除附件
  167. function deleteRow(objTable,rowid){
  168.  var tbodyOnlineEdit=objTable.getElementsByTagName("TBODY")[0];
  169.  if(rowid!=""){
  170.  for (var i=tbodyOnlineEdit.children.length-1; i>=0 ;i-- ){
  171.      if (tbodyOnlineEdit.children[i].id==rowid){tbodyOnlineEdit.deleteRow(i)};
  172.    }
  173.    }
  174. }
  175. //设置所以附件路径
  176. function setFiles(){
  177.  var tbodyOnlineEdit=attachTable.getElementsByTagName("TBODY")[0];
  178.  var ff ="";
  179. for (var i=tbodyOnlineEdit.children.length-1; i>0 ;i-- ){
  180.  ff += tbodyOnlineEdit.children[i].children[1].children[0].value+"&&";
  181. }
  182.  ff += tbodyOnlineEdit.children[0].children[1].children[0].value
  183. EditForm.fs.value=ff;
  184. }
  185. //-->
  186. </script>
  187. <link href="css/style.css" rel="stylesheet" type="text/css">
  188. </head>
  189. <body bgcolor="#F2F1F2" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" scroll="no" background="images/login_bg.gif">
  190. <div style="overflow: auto;height:100%;width:100%;">
  191.   <table width="100%"  border="0" cellspacing="0" cellpadding="0">
  192.     <tr>
  193.       <td width="11" height="11"></td>
  194.       <td ></td>
  195.     </tr>
  196.   </table>
  197.   <table width="100%" height="98%"  border="0" cellpadding="0" cellspacing="0">
  198.     <tr>
  199.       <td width="11" background="images/1.gif">&nbsp;</td>
  200.       <td align="center" valign="top" bgcolor="ECF4F5">
  201.           <table width="99%" border="0" >
  202.             <form  method="post" enctype="multipart/form-data" name="EditForm"  id="EditForm"  action="writeMail.do">
  203. <input type="hidden" name="easyJWebCommand" value="save">
  204. <input type="hidden" name="subCommand" value="">
  205. <input name="editMode" type="hidden" id="editMode" value="html">
  206.             <input name="text" type="hidden" id="text" value="">
  207. <input name="cid" type="hidden" value="">                 
  208. <input name="box" type="hidden" value="draftbox">    
  209. <input name="fs" type="hidden" value="">                
  210.               <tr>
  211.                 <td ><table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  212.                   <tr align="center"> 
  213.                     <td width="200" align="center" colspan="2"><font color="#FF0000">收件人、抄送人地址请用逗号隔开</font></td>
  214.                     <td width="50" class="coolbutton" style="cursor: hand;" onClick="doSend()" ><img  src="images/posts.gif" width="16" height="16" border="0" align="absmiddle">发送</td>
  215.                     <td width="50"></td>
  216.                     <td width="50" class="coolbutton" style="cursor: hand;" onClick="return doSave();" ><img  src="images/copyToDisk0a.gif" width="16" height="16" border="0" align="absmiddle">保存</td>
  217.                     <td width="50"></td>
  218.                     <td width="90" class="coolbutton" style="cursor: hand;" onClick="doSendAndSave();" ><img  src="images/mail.gif" width="16" height="16" border="0" align="absmiddle">发送并保存</td>
  219.                     <td width="50"></td>
  220.                   </tr>
  221.                   <tr> 
  222.                     <td colspan="1" width="10%" align="center" nowrap class="coolbutton" style="cursor: hand;" onClick="choiceAddress(EditForm.toUser);">收件人:</td>
  223.                     <td colspan="6" width="90%"><input name="toUser" type="text" class="Max" id="toUser" value="">                    </td>
  224.                   </tr>
  225.                   <tr> 
  226.                     <td colspan="1" width="10%" align="center" class="coolbutton" style="cursor: hand;" onClick="choiceAddress(EditForm.copyTo);">抄&nbsp;&nbsp;送:</td>
  227.                     <td colspan="6" width="90%"><input name="copyTo" type="text" class="Max" id="copyTo" value=""></td>
  228.                   </tr>
  229.     <tr> 
  230.                     <td colspan="1" width="10%" align="center" class="coolbutton" style="cursor: hand;" onClick="choiceAddress(EditForm.secretTo);">暗&nbsp;&nbsp;送:</td>
  231.                     <td colspan="6" width="90%"><input name="secretTo" type="text" class="Max" id="secretTo" value=""></td>
  232.                   </tr>
  233.                   <tr> 
  234.                     <td colspan="1" width="10%" align="center">主&nbsp;&nbsp;题:</td>
  235.                     <td colspan="6" width="90%"><input name="subject" type="text" class="Max" id="subject" value=""></td>
  236.                   </tr>
  237.                   <tr> 
  238.                     <td width="10%" colspan="1" align="center">优先级:</td>
  239.                     <td><select name="priority" id="priority" >
  240.                         <option value="3" >一般</option>
  241.                         <option value="1" >高</option>
  242.                         <option value="5" >低</option>
  243.                       </select></td>
  244.                     <td colspan="2">需要已接收回执
  245.                       <input type="checkbox" name="needAutoReply" id="needAutoReply" value="1" >                    </td>
  246.                     <td colspan="2">&nbsp;</td>
  247.                     <td align="center"><a href="#" target="_self" onClick="changeEdit(this);">文本编辑器</a>                    </td>
  248.                   </tr>
  249.                   <tr id="htmlView" style="display:"> 
  250.                     <td colspan="7" width="100%"><iframe id='htmlRichedit' name='htmlRichedit' width="100%" height="350" src="include/inedit.htm"></iframe>
  251.                     <span id="htmlTempSpan" style="display:none"></span></td>
  252.                   </tr>
  253.                   <tr id="textView" style="display:none"> 
  254.                     <td bgcolor="#C1F9FD" colspan="7" width="100%"><textarea id='richedit' name='richedit' cols="82" rows="19" maxlength="1000000" style="width:100% "></textarea></td>
  255.                   </tr>
  256.                   <tr> 
  257.                     <td colspan="7" width="100%">
  258. <table width="100%" border="0" id="attachTable">
  259. <tbody>
  260.                         <tr id="dataRow0"> 
  261.                           <td width="60">附 件 : </td>
  262.                           <td><input type="file" name="file0" contenteditable="false"/>
  263.                               <a href="#" onClick="deleteRow(attachTable,this.parentElement.parentElement.id);" >删除附件</a></td>
  264.                         </tr>
  265. </tbody>
  266.                       </table>                    </td>
  267.                   </tr>
  268.                   <tr>
  269.                     <td colspan="7">当前已有附件:
  270.                        <input name="addAccessory" type="button" class="TableTitle" style="cursor: hand;" id="addAccessory" value="添加附件" 
  271.    onclick="addRow(attachTable);"/>
  272.                       提示:您能发送的邮件附件总容量最大为15M! </td>
  273.                   </tr>
  274.                   <tr>
  275.                     <td colspan="7">&nbsp;</td>
  276.                   </tr>
  277.                 </table></td>
  278.               </tr>
  279.       </table></td>
  280.       <td width="11" bgcolor="ECF4F5">&nbsp;</td>
  281.     </tr>
  282.   </table>
  283. <script language="javascript">
  284. if(EditForm.editMode.value!=''&&EditForm.editMode.value=='html')
  285. {
  286. window.setTimeout('eee()',500);
  287. }
  288. function eee()
  289. {
  290. if(EditForm.editMode.value!=''&&EditForm.editMode.value=='html')
  291. {
  292. htmlRichedit.setHTML(EditForm.richedit.value);
  293. }
  294. }
  295. window.setTimeout('document.all("toUser").focus()',1);
  296. </script>  
  297. </div>
  298. </body>
  299. </html>