pop3_getmail_do111.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:5k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=utf-8" %>
  2. <%@ page import="com.redmoon.oa.emailpop3.*"%>
  3. <%@ page import="cn.js.fan.web.*"%>
  4. <%@ page import="cn.js.fan.util.*"%>
  5. <%@ page import="cn.js.fan.mail.*"%>
  6. <%@ page import="java.util.*"%>
  7. <%@ page import="javax.mail.*"%>
  8. <html>
  9. <head>
  10. <title>取邮件</title>
  11. <link href="../common.css" rel="stylesheet" type="text/css">
  12. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
  13. <%@ include file="../inc/nocache.jsp" %>
  14. <body leftmargin="0" topmargin="5">
  15. <jsp:useBean id="fchar" scope="page" class="cn.js.fan.util.StrUtil"/>
  16. <jsp:useBean id="userservice" scope="page" class="com.redmoon.oa.person.UserService"/>
  17. <jsp:useBean id="fnumber" scope="page" class="cn.js.fan.util.NumberUtil"/>
  18. <jsp:useBean id="cfgparser" scope="page" class="cn.js.fan.util.CFGParser"/>
  19. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  20. <%
  21. if (!privilege.isUserLogin(request))
  22. {
  23. out.println(SkinUtil.makeInfo(request, SkinUtil.LoadString(request, "pvg_invalid")));
  24. return;
  25. }
  26. int id = -1;
  27. try {
  28. id = ParamUtil.getInt(request, "id");
  29. }
  30. catch (ErrMsgException e) {
  31. out.print(SkinUtil.makeErrMsg(request, "请选择邮箱!"));
  32. return;
  33. }
  34. %>
  35. <br>
  36. <%
  37. EmailPop3Db epd = new EmailPop3Db();
  38. epd = epd.getEmailPop3Db(id);
  39. if (!epd.getUserName().equals(privilege.getUser(request))) {
  40. out.println(SkinUtil.makeErrMsg(request, SkinUtil.LoadString(request, "pvg_invalid")));
  41. }
  42. String email = epd.getEmail();
  43. String mailserver = epd.getServer();
  44. int port = epd.getPort();
  45. String email_name = epd.getEmailUser();
  46. String email_pwd_raw = epd.getEmailPwd();
  47. GetMail getmail = new GetMail(mailserver,port,email_name,email_pwd_raw);
  48. Message[] msgs = null;
  49. String type = "list";
  50. try { 
  51. msgs = getmail.receive(type);
  52. }
  53. catch (ErrMsgException e) {
  54. out.print(cn.js.fan.web.SkinUtil.makeErrMsg(request, e.getMessage()));
  55. return;
  56. }
  57. String mailID = "";
  58. if (msgs==null)
  59. {
  60. out.println(cn.js.fan.web.SkinUtil.makeErrMsg(request, "无邮件!"));
  61. }
  62. else {
  63. %>
  64. <form id=form1 name=form1 action="pop3_opmail.jsp" method="post">
  65.   <table width="96%" border="0" align="center" cellpadding="2" cellspacing="0" class="stable">
  66.     <tr align="middle" bgcolor="#C4DAFF" class="stable">
  67.       <td width="6%" class="stable">&nbsp;</td>
  68.       <td width="8%" align="center" nowrap class="stable">优 先</td>
  69.       <td width="8%" align="center" nowrap class="stable">状 态</td>
  70.       <td width="21%" align="center" nowrap class="stable">发件人</td>
  71.       <td width="22%" align="center" nowrap class="stable">主 题</td>
  72.       <td width="19%" align="center" nowrap class="stable">日 期</td>
  73.       <td width="16%" align="center" nowrap class="stable">大 小</td>
  74.     </tr>
  75.   </table>
  76.   <%
  77. int len = msgs.length;
  78.         for(int msgNum = 0; msgNum < len; msgNum++) {
  79.            MailMsg msg = getmail.getMessage(msgs[msgNum]);
  80.            if (msg.getMessage().isSet(Flags.Flag.DELETED))
  81.                ;//logger.error("It is deleted");
  82.    boolean isShow = false;
  83.            if (type.equals(type)) {
  84.               if (!msg.isDeleted())
  85.                   isShow = true;
  86.            }
  87.            else if (type.equals("dustbin")) {
  88.               if (msg.isDeleted())
  89.                  isShow = true;
  90.            }
  91.            else
  92.               isShow = true;
  93.       if (isShow) {
  94.   mailID = msg.getID();
  95.   java.util.Date senddate = msg.getSentDate();
  96.   String d = senddate==null?"":DateUtil.format(senddate, "yyyy-MM-dd HH:mm:ss");
  97. %>
  98.   <table width="96%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#C6DBFF">
  99.     <tr class="stable" align="center">
  100.       <td width="6%" bgcolor="#FFFFFF"><input title="选择/不选" type="checkbox" value="<%=msg.getID()%>" name="mailids"></td>
  101.       <td width="8%" bgcolor="#FFFFFF">&nbsp;</td>
  102.       <td width="8%" bgcolor="#FFFFFF">&nbsp;</td>
  103.       <td width="21%" bgcolor="#FFFFFF"><a href="pop3_sendmail_html.jsp?to=<%=msg.getSender()%>&email=<%=email%>"><%=msg.getFrom()%></a></td>
  104.       <td width="22%" bgcolor="#FFFFFF"><a href="pop3_showmail.jsp?mailid=<%=msg.getID()%>&email=<%=email%>&mailserver=<%=mailserver%>&port=<%=port%>&email_user=<%=email_name%>&email_pwd=<%=email_pwd_raw%>"><%=msg.getSubject()%></a></td>
  105.       <td width="19%" bgcolor="#FFFFFF"><%=d%></td>
  106.       <td width="16%" bgcolor="#FFFFFF"><%=fnumber.round((double)msg.getSize()/1000,2)%> k
  107.         <%
  108. if (msg.hasAttachment()) {%>
  109.           <img src="images/attach.gif">
  110.           <%}
  111. %>
  112.       </td>
  113.     </tr>
  114.   </table>
  115.   <%   
  116. }
  117. }
  118. getmail.close();
  119. %>
  120.   <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  121.     <tr>
  122.       <td align="center"><br>
  123.           <input type="hidden" name="op">
  124.           <input type="hidden" name="email" value="<%=email%>">
  125.         <a href="javascript:form1.op.value='del';form1.submit()">删除所选邮件</a></td>
  126.     </tr>
  127.   </table>
  128. </form>
  129. <%}%>
  130. </body>
  131. </html>