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

WEB邮件程序

开发平台:

Java

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