/** * @param rundata * @param context * @param msgList * @return * @throws ALPageNotFoundException * @throws ALDBErrorException */ @Override protected boolean setFormData(RunData rundata, Context context, List<String> msgList) throws ALPageNotFoundException, ALDBErrorException { boolean res = super.setFormData(rundata, context, msgList); if (accountId <= 0 || userId <= 0) { return res; } try { fileuploadList = FileuploadUtils.getFileuploadList(rundata); // Body // オブジェクトモデルを取得 EipMMailAccount account = ALMailUtils.getMailAccount(userId, accountId); // 署名を本文に追加 if (!ALEipConstants.MODE_INSERT.equals(rundata.getParameters().get(ALEipConstants.MODE)) && account.getSignature() != null && !"".equals(account.getSignature())) { StringBuffer bodybuf = new StringBuffer(); if (body.getValue() != null) { bodybuf.append(body.getValue()); } bodybuf.append("\r\n\r\n\r\n"); bodybuf.append(account.getSignature()); body.setValue(bodybuf.toString()); } } catch (Exception ex) { logger.error("webmail", ex); } return res; }
/** * @param rundata * @param context * @param msgList * @return */ @Override protected boolean loadFormData(RunData rundata, Context context, List<String> msgList) { mailType.setValue(rundata.getParameters().getInt(WebMailUtils.MAIL_TYPE, TYPE_NEW_MAIL)); try { ALLocalMailMessage msg = (ALLocalMailMessage) WebMailUtils.getSelectedLocalMailMessage( rundata, context, (int) getMailType().getValue()); if (msg == null) { return false; } String tmpSubject = null; if (getMailType().getValue() == TYPE_NEW_MAIL) { // unreachable flow // TO Address[] tos = msg.getRecipients(Message.RecipientType.TO); this.setTo(ALMailUtils.getAddressString(tos)); // CC Address[] ccs = msg.getRecipients(Message.RecipientType.CC); this.setCc(ALMailUtils.getAddressString(ccs)); // BCC Address[] bccs = msg.getRecipients(Message.RecipientType.BCC); this.setBcc(ALMailUtils.getAddressString(bccs)); tmpSubject = msg.getSubject(); } else if (getMailType().getValue() == TYPE_REPLY_MAIL) { // TO this.setTo(ALMailUtils.getFromDelegateExtract(msg)); tmpSubject = "Re: " + msg.getSubject(); } else if (getMailType().getValue() == TYPE_FORWARD_MAIL) { tmpSubject = "Fwd: " + msg.getSubject(); } else if (getMailType().getValue() == TYPE_REPLY_ALL_MAIL) { // TO Address[] from = ALMailUtils.getFromDelegateExtractForAddress(msg); Address[] to = msg.getRecipients(Message.RecipientType.TO, false); EipMMailAccount myaccount = ALMailUtils.getMailAccount(userId, accountId); String myaddress = myaccount.getMailAddress(); List<Address> allList = new ArrayList<Address>(); allList.addAll(Arrays.asList(from)); allList.addAll(Arrays.asList(to)); List<Address> replayList = new ArrayList<Address>(); for (Address address : allList) { if (address instanceof InternetAddress) { InternetAddress internetAddress = (InternetAddress) address; String email = internetAddress.getAddress(); if (email != null && !email.equalsIgnoreCase(myaddress) && !email.contains("<" + myaddress + ">")) { replayList.add(address); } } } this.setTo( ALMailUtils.getAddressString(replayList.toArray(new Address[replayList.size()]))); // CC Address[] ccs = msg.getRecipients(Message.RecipientType.CC, false); this.setCc(ALMailUtils.getAddressString(ccs)); // BCC Address[] bccs = msg.getRecipients(Message.RecipientType.BCC); this.setBcc(ALMailUtils.getAddressString(bccs)); tmpSubject = "Re: " + msg.getSubject(); } // Subject this.setSubject(tmpSubject); // 返信の原文付与 String[] tmp2 = msg.getBodyTextArray(); StringBuffer replies = new StringBuffer(); replies.append("\r\n\r\n\r\n" + "------Original Message-------\r\n"); if (tmp2 != null) { for (String factor : tmp2) { replies.append("> " + factor + "\r\n"); } } // Body try { // オブジェクトモデルを取得 EipMMailAccount account = ALMailUtils.getMailAccount(userId, accountId); // 署名と返信とを本文に追加 if (account.getSignature() != null && !"".equals(account.getSignature())) { body.setValue(replies + "\r\n\r\n\r\n" + account.getSignature()); } else { body.setValue(replies.toString()); } } catch (Exception ex) { logger.error("webmail", ex); } if (getMailType().getValue() == TYPE_FORWARD_MAIL) { msg = (ALLocalMailMessage) WebMailUtils.getSelectedLocalMailMessage(rundata, context, TYPE_NEW_MAIL); if (msg == null) { return false; } String[] filenames = msg.getAttachmentFileNameArray(); if (filenames != null && filenames.length > 0) { /** 添付ファイルを含んだメールを転送する */ if (folderName == null || folderName.equals("")) { folderName = "undefined"; } for (int i = 0; i < filenames.length; i++) { /** 各々の添付ファイルを、一度ファイルに書き出して再度添付する */ int fileId = Long.valueOf(System.nanoTime()).intValue(); String newAttachmentFileName = String.valueOf(fileId); String realfilename = filenames[i]; if (realfilename == null) { continue; } ALStorageService.createNewTmpFile( msg.getInputStream(i), userId, folderName, newAttachmentFileName, realfilename); FileuploadLiteBean filebean = new FileuploadLiteBean(); filebean.initField(); filebean.setFileId(fileId); filebean.setFileName(realfilename); filebean.setFolderName(folderName); fileuploadList.add(filebean); } } } return true; } catch (Exception e) { logger.error("webmail", e); return false; } }