⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 replyall.jsp

📁 一个实现邮件收发功能的客户端程序
💻 JSP
字号:
<%@ page contentType="text/html; charset=utf-8" session="true" errorPage="frame_user_error.jsp" %>
<%@ include file="validate.jsp" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="net.meybo.mail.client.*" %>
<%@ page import="net.meybo.util.*" %>
<%
	String from="";
	String text="";
	String toUser="";
	String copyTo="";
	String secretTo="";
	String subject="";
	java.util.List attachs=new java.util.ArrayList();
	String cid=CommUtil.null2String(request.getParameter("cid"));
	String box=CommUtil.null2String(request.getParameter("box"));
	box=new String(box.getBytes("iso-8859-1"),"utf-8");
	String editMode="";
	boolean hasAttachs=false;
	if(cid!=null&&!"".equals(cid)&&box!=null&&!"".equals(box)) {
		MimeMessage mail=EmailManage.getMail(user.getUserName(),user.getServerDomain(),box,cid);
		if(mail!=null) {
			mail=(MimeMessage)mail.reply(true);
			ParseMimeMessage email=new ParseMimeMessage(mail);
			try {
	//			form.addResult("from",email.getFrom());
	//			form.addResult("text",email.getMailContent());
	//			form.addResult("toUser",email.getMailAddress("TO"));
	//			form.addResult("copyTo",email.getMailAddress("CC"));
	//			form.addResult("secretTo",email.getMailAddress("BCC"));
	//			form.addResult("subject",email.getSubject());
	//			form.addResult("attachs",email.getAttachMent());
				from=CommUtil.null2String(email.getFrom());
				text=CommUtil.null2String(email.getMailContent());
				text="";
				toUser=CommUtil.null2String(email.getMailAddress("TO"));
				copyTo=CommUtil.null2String(email.getMailAddress("CC"));
				secretTo=CommUtil.null2String(email.getMailAddress("BCC"));
				subject=CommUtil.null2String(email.getSubject());
//				attachs=email.getAttachMent();
//				if(attachs!=null && attachs.size()>0)
//					hasAttachs=true;
//				if(email.isHtml())editMode="html";
			}
			catch(Exception e) {
			}
		}
	}
	
	String htmlView="",textView="",editModeTitle="可视化编辑器";
	if(editMode.equals("html"))
	{textView="none";
		editModeTitle="文本编辑器";
	}
	else htmlView="none";
//	System.out.println(editMode);
//	form.addResult("editMode",editMode);
//	form.addResult("htmlView",htmlView);
//	form.addResult("textView",textView);
//	form.set("cid",cid);
//	form.addResult("editModeTitle",editModeTitle);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>回复所有</title>
<script language="JavaScript" src="include/CheckDataFunction.js" type="text/JavaScript"></script>
<script language="javascript">
<!--
function doSendAndSave()
{
	if(setSend())
	{
		//EditForm.easyJWebCommand.value="sendSave";
		EditForm.action="sendsave.jsp";
		EditForm.submit();
	}
	else
		return false;
}//sendsave 
function doSend()
{
	if(setSend())
	{
		//EditForm.easyJWebCommand.value="send";
		EditForm.action="send.jsp";
		EditForm.submit();
	}
	else
		return false;
}//sendsave
function doSave()
{
	if(setSend())
	{
		//EditForm.easyJWebCommand.value="save";
		EditForm.action="save.jsp";
		EditForm.submit();
	}
	else
		return false;
}//sendsave

function choiceAddress(Obj)
{
	var str='';
	urls="selectuser3/index.jsp";
	str=window.showModalDialog(urls,"addAccessory","dialogWidth:600px;dialogHeight:450px;help:no;status:auto");
	choice(Obj,str)
}
function choice(Obj,str)
{
	var allValue=Obj.value;
	if(str!=null)
	{
		if(allValue!=null && allValue!="")
		{
			allValue = allValue+",";
		}
		var tmpValue='';
		var Value=str.split('<>');
		for(var x=0;x<Value.length;x++)
		{
			if(Value[x]!='')
			{
				tmpValue=Value[x].split('|')
				if(allValue.indexOf(tmpValue[0])==-1)
					allValue+= tmpValue[0]+",";
			}
		}
	}
	Obj.value = allValue.substring(0,allValue.length-1);
}

function DelCID(Obj)
{
	for(var x=Obj.length-1;x>=0;x--)
	{
		if(Obj.options[x].selected)
		{
			Obj.options[x]=null;
		}
	}
}

function changeEdit(obj)
{
	if(EditForm.editMode.value == 'html')
	{
		if(!window.confirm('警告:如果将该邮件格式改为纯文本,可能会造成格式信息丢失!'))
		return false;
		EditForm.editMode.value = '1';
		EditForm.text.value = htmlRichedit.getPureText();
		EditForm.richedit.value= htmlRichedit.getPureText();
		htmlView.style.display="none";
		textView.style.display="";
	}
	else
	{
		EditForm.editMode.value = 'html';
		htmlRichedit.setHTML('<div><pre>'+EditForm.richedit.value+'</pre></div>');
		htmlView.style.display="";
		textView.style.display="none";
	}
	if(obj.innerText=="可视化编辑器")obj.innerText="文本编辑模式";
	else obj.innerText="可视化编辑器";
	return false;
}
function setSend()
{
	var x,n
	var accessoryValue='<>';
	if(Trim(EditForm.toUser.value)=="")
	{
		alert('请输入收件人');
		EditForm.toUser.focus();
		return false;
	}
	if(EditForm.copyTo.length>=1000)
	{
		alert('邮件最多只能抄送10位接收者!\n如要发送给多个人员,请选择多个收件人!');
		EditForm.copyTo.focus();
		return false;
	}
	if(Trim(EditForm.subject.value)=='')
	{
		alert('请输入主题!');
		EditForm.subject.focus();
		return false;
	}
	// EditForm.accessory.value =accessoryValue;	
	if(EditForm.editMode.value=="html") {
		var source=htmlRichedit.getHTML();
		source=praseScript(source)
		EditForm.text.value = '<html>'+source+'</html>';
	}
	else
		EditForm.text.value = EditForm.richedit.value;
		//	alert(EditForm.text.value);
	if(typeof EditForm.fileName !="undefined") {
		var obj=EditForm.fileName;
		var names="";
		if(obj.length>1) {
			for(var i=0;i<obj.length;i++) {
				if(names=="") {
					names=obj[i].value;
				}
				else {
					names=names+","+obj[i].value;
				}
			}
		}
		else {
			names=obj.value;
		}
		EditForm.files.value=names;
	}
	//alert(EditForm.files.value);
	return true;
}
function praseScript(reMsg) {
	reMsg=reMsg.replace(/script/gi,"script$1");
	//reMsg=reMsg.replace(/on/gi,"On$1");
	return reMsg;
}
var fileCount=1;
function addRow(objTable){
	//var firstRow=" <tr><td width=\"60\">附 件 : </td><td><input type=\"file" name=\"file0\"></td></tr>";
	var tbodyOnlineEdit=objTable.getElementsByTagName("TBODY")[0];
	if(typeof tbodyOnlineEdit.children[0]=="undefined" || tbodyOnlineEdit.children[0]== null) {
		var tr=document.createElement("TR");
		tr.id="dataRow0";
		var td1=document.createElement("TD");
		td1.style.width="60";
		td1.innerText="附 件 : ";
		var td2=document.createElement("TD");
		td2.innerHTML="<input type=\"file\" name=\"file0\" class=\"inputbox\"><a href=\"#\" onClick=\"deleteRow(attachTable,this.parentElement.parentElement.id);\">删除附件</a>";
		tr.appendChild(td1);
		tr.appendChild(td2);
		tbodyOnlineEdit.appendChild(tr);
	}
	else {
		var elm = tbodyOnlineEdit.children[0].cloneNode(true);

		elm.id="dataRow"+fileCount++;//设置行的ID 
		//设置表单name 
		elm.children[1].children[0].name="file"+fileCount;

		// elm.children[2].children[0].name="amountT"+countId;
		//插入表单
		tbodyOnlineEdit.insertBefore(elm);
	}
}
function deleteRow(objTable,rowid){
	var tbodyOnlineEdit=objTable.getElementsByTagName("TBODY")[0];
	if(rowid!="") {
	for (var i=tbodyOnlineEdit.children.length-1; i>=0 ;i-- )
		if (tbodyOnlineEdit.children[i].id==rowid)tbodyOnlineEdit.deleteRow(i);
	}
}
function delFile(ids) {
	for(var i=0;i<trFiles.children.length;i++) {
		if(trFiles.children[i].id==ids) {
			trFiles.deleteCell(i);
		}
	}
}
//-->
</script>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" scroll="AUTO">
  <table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="11" background="images/1.gif">&nbsp;</td>
      <td align="center" valign="top" bgcolor="ECF4F5">
          <table width="100%" border="0" >
            <form  method="post" enctype="multipart/form-data" name="EditForm"  id="EditForm"  action="save.jsp">
			<input type="hidden" name="easyJWebCommand" value="save">
			<input type="hidden" name="subCommand" value="">
			<input name="editMode" type="hidden" id="editMode" value="<%=editMode%>">
            <input name="text" type="hidden" id="text" value="">
			<input name="cid" type="hidden" value="<%=cid%>">
			<input name="box" type="hidden" value="<%=box%>">
			<input type="hidden" name="files" value="">
              <tr>
                <td ><table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr align="center"> 
                    <td width="200" align="center" colspan="2"><font color="#FF0000">收件人、抄送人地址请用逗号隔开</font></td>
                    <td width="50" class="coolbutton" style="cursor: hand;" onClick="doSend()"><img  src="images/posts.gif" width="16" height="16" border="0" align="absmiddle">发送</td>
                    <td width="20"></td>
                    <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>
                    <td width="20"></td>
                    <td width="90" class="coolbutton" style="cursor: hand;" onClick="doSendAndSave();"><img  src="images/mail.gif" width="16" height="16" border="0" align="absmiddle">发送并保存</td>
                    <td class="coolbutton" style="cursor: hand;" onClick="history.back();" nowrap><img src='images/exit.gif' width='20' height='18' border='0' align='absmiddle'>返回</td>
                  </tr>
                  <tr> 
                    <td colspan="1" width="10%" align="center" nowrap class="coolbutton" style="cursor: hand;" onClick="choiceAddress(EditForm.toUser);">收件人:</td>
                    <td colspan="7" width="90%"><input name="toUser" type="text" class="Max1 inputbox" id="toUser" value="<%=toUser%>"></td>
                  </tr>
                  <tr> 
                    <td colspan="1" width="10%" align="center" class="coolbutton" style="cursor: hand;" onClick="choiceAddress(EditForm.copyTo);">抄&nbsp;&nbsp;送:</td>
                    <td colspan="7" width="90%"><input name="copyTo" type="text" class="Max1 inputbox" id="copyTo" value="<%=copyTo%>"></td>
                  </tr>
				    <tr> 
                    <td colspan="1" width="10%" align="center" class="coolbutton" style="cursor: hand;" onClick="choiceAddress(EditForm.secretTo);">暗&nbsp;&nbsp;送:</td>
                    <td colspan="7" width="90%"><input name="secretTo" type="text" class="Max1 inputbox" id="secretTo" value="<%=secretTo%>"></td>
                  </tr>
                  <tr> 
                    <td colspan="1" width="10%" align="center">主&nbsp;&nbsp;题:</td>
                    <td colspan="7" width="90%"><input name="subject" type="text" class="Max1 inputbox" id="subject" value="<%=subject%>"></td>
                  </tr>
                  <tr> 
                    <td width="10%" align="center">优先级:</td>
                    <td><select name="priority" id="priority" >
                        <option value="3" >一般</option>
                        <option value="1" >高</option>
                        <option value="5" >低</option>
                      </select></td>
                    <td colspan="2">需要已接收回执
                      <input type="checkbox" name="needAutoReply" id="needAutoReply" value="1"></td>
                    <td colspan="2">&nbsp;</td>
                    <td align="center" colspan="2"><a href="#" target="_self" onClick="changeEdit(this);"><%=editModeTitle%></a></td>
                  </tr>
                  <tr id="htmlView" style="display:<%=htmlView%>"> 
                    <td colspan="8" width="100%"><iframe id='htmlRichedit' name='htmlRichedit' width="100%" height="350" src="include/inedit.htm"></iframe>
                    <span id="htmlTempSpan" style="display:none"></span></td>
                  </tr>
                  <tr id="textView" style="display:<%=textView%>"> 
                    <td colspan="8" width="100%"><textarea id='richedit' name='richedit' cols="82" rows="19" maxlength="1000000" class="Max2 textbox"><%=text%></textarea></td>
                  </tr>
                  <tr> 
                    <td colspan="8" width="100%">
					<table width="100%" border="0" id="attachTable">
					<tbody>
                        <tr id="dataRow0"> 
                          <td width="60">附 件 : </td>
                          <td><input type="file" name="file0" class="inputbox">
                              <a href="#" onClick="deleteRow(attachTable,this.parentElement.parentElement.id);">删除附件</a></td>
                        </tr>
						</tbody>
                      </table>
					</td>
                  </tr>
                  <tr>
                    <td colspan="8">
                      <input name="addAccessory" type="button" class="inputbtn" id="addAccessory" value="添加附件" onClick="addRow(attachTable);">
                      提示:您能发送的邮件附件总容量最大为25M! </td>
                  </tr>
				  <%if(hasAttachs){%>
                  <tr>
                    <td colspan="8">当前已有<%=attachs.size()%>附件:
					<DIV class="divFiles">
					<TABLE border=0 cellSpacing=0 cellPadding=0>
					<TBODY>
					<TR id="trFiles">
					<%for(int i=0;i<attachs.size();i++) {
						java.util.Map info=(java.util.Map)attachs.get(i);
						//out.println(info.get("description")+"("+info.get("size")+")"+" &nbsp;&nbsp;");%>
						<TD class="trnormal" onmouseover="this.className='trselect'" onmouseout="this.className='trnormal'" id="td<%=i%>">
						<img src="images/<%=info.get("img")%>" width="24" height="24" border="0" align="absmiddle" title="<%=info.get("description")%>"><%=info.get("fileName")+"("+info.get("size")+")"%><br/><a href="download.jsp?cid=<%=cid%>&box=<%=box%>&fileName=<%=common.Function.encode((String)info.get("fileName"))%>" target="_blank">下载</a>&nbsp;&nbsp;<a href="javascript:delFile('td<%=i%>')">删除</a>
						<input type="hidden" name="fileName" value="<%=info.get("fileName")%>">
						</TD>
						<%
					}
					%>
					</TR></TBODY></TABLE>
					</div>
                      </td>
                  </tr>
				  <%}%>
                  <tr>
                    <td colspan="8">&nbsp;</td>
                  </tr>
                </table></td>
              </tr>
            </form>
      </table></td>
      <td width="11" bgcolor="ECF4F5">&nbsp;</td>
    </tr>
  </table>
<script language="javascript">
if(EditForm.editMode.value!=''&&EditForm.editMode.value=='html')
{
	window.setTimeout('eee()',500);
}
function eee()
{
	if(EditForm.editMode.value!=''&&EditForm.editMode.value=='html')
	{
		htmlRichedit.setHTML(EditForm.richedit.value);
	}
}
window.setTimeout('document.all("toUser").focus()',1);
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -